[ create a new paste ] login | about

Link: http://codepad.org/ojU3s9xM    [ raw code | output | fork ]

PHP, pasted on May 29:
<?php

function y($x) {
    return $x * $x / 7;
}
function x($y) {
	return 7 * sqrt($y);
}

$theArray = range(0,100);
$size = count($theArray);

//use func inverse to find the max value we can input to $y() without going out of array bounds
$maximumX = x($size);
for ($i=0; $i<$maximumX; $i++) {
    $index = (int) y($i);
	
	//unset the index if it still exists, else, the next greatest index
	while (!isset($theArray[$index]) && $index < $size) {
	    $index++;
	}
	
    unset($theArray[$index]);
}




for ($i=0; $i<$size; $i++) {
	printf("[%-3s]", isset($theArray[$i]) ? $theArray[$i] : '');
}


Output:
1
[   ][   ][   ][   ][   ][   ][   ][   ][8  ][   ][10 ][   ][12 ][13 ][   ][15 ][16 ][   ][18 ][19 ][   ][21 ][22 ][23 ][   ][25 ][26 ][27 ][   ][29 ][30 ][31 ][   ][33 ][34 ][35 ][   ][37 ][38 ][39 ][40 ][   ][42 ][43 ][44 ][45 ][   ][47 ][48 ][49 ][50 ][   ][52 ][53 ][54 ][55 ][56 ][   ][58 ][59 ][60 ][61 ][62 ][   ][64 ][65 ][66 ][67 ][68 ][   ][70 ][71 ][72 ][73 ][74 ][   ][76 ][77 ][78 ][79 ][80 ][81 ][   ][83 ][84 ][85 ][86 ][87 ][88 ][   ][90 ][91 ][92 ][93 ][94 ][95 ][   ][97 ][98 ][99 ][100]


Create a new paste based on this one


Comments: