[ create a new paste ] login | about

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

pauld - PHP, pasted on Jul 14:
<?php
$input = '38,39';
$line = '';
$output = '';
$output_arr = array();
$input_array = explode(',',$input);
$line_array = array();

// create input string
for($i=0;$i<40;++$i){ 
	$add = ' ';
	foreach ($input_array as $key=>$value) {	
		if ($value == $i){
			$add = 'x';
		}
	}
	$line .= $add;
}
echo  $line."\n";

for($x=1;$x<50;++$x){ 
	$output = '';
	for($i=1;$i<41;++$i){ 

		if (($i > 1) AND (substr($line, $i-2, 1) == 'x')) { 
			$above_left = 1; 
		} else { 
			$above_left = 0; 
		}

		if ((substr($line, $i-1, 1)) == 'x') { 
			$above = 1; 
		} else { 
			$above = 0; 
		}

		if ((substr($line, $i, 1)) == 'x') { 
			$above_right = 1; 
		} else { 
			$above_right = 0; 
		}
		
		if ((($above_left + $above + $above_right) == 2) OR (($above + $above_right) == 1)) {
			$output .= 'x';
		} else {
			$output .= ' ';
		}
	}

	echo $output."\n";

	$line = $output; 

}

// $output_arr = array();
// $input_array = explode(',',$input);
// $line_array = array();

?>


Output:
                                      xx
                                     xxx
                                    xx x
                                   xxxxx
                                  xx   x
                                 xxx  xx
                                xx x xxx
                               xxxxxxx x
                              xx     xxx
                             xxx    xx x
                            xx x   xxxxx
                           xxxxx  xx   x
                          xx   x xxx  xx
                         xxx  xxxx x xxx
                        xx x xx  xxxxx x
                       xxxxxxxx xx   xxx
                      xx      xxxx  xx x
                     xxx     xx  x xxxxx
                    xx x    xxx xxxx   x
                   xxxxx   xx xxx  x  xx
                  xx   x  xxxxx x xx xxx
                 xxx  xx xx   xxxxxxxx x
                xx x xxxxxx  xx      xxx
               xxxxxxx    x xxx     xx x
              xx     x   xxxx x    xxxxx
             xxx    xx  xx  xxx   xx   x
            xx x   xxx xxx xx x  xxx  xx
           xxxxx  xx xxx xxxxxx xx x xxx
          xx   x xxxxx xxx    xxxxxxxx x
         xxx  xxxx   xxx x   xx      xxx
        xx x xx  x  xx xxx  xxx     xx x
       xxxxxxxx xx xxxxx x xx x    xxxxx
      xx      xxxxxx   xxxxxxxx   xx   x
     xxx     xx    x  xx      x  xxx  xx
    xx x    xxx   xx xxx     xx xx x xxx
   xxxxx   xx x  xxxxx x    xxxxxxxxxx x
  xx   x  xxxxx xx   xxx   xx        xxx
 xxx  xx xx   xxxx  xx x  xxx       xx x
xx x xxxxxx  xx  x xxxxx xx x      xxxxx
xxxxxx    x xxx xxxx   xxxxxx     xx   x
x    x   xxxx xxx  x  xx    x    xxx  xx
x   xx  xx  xxx x xx xxx   xx   xx x xxx
x  xxx xxx xx xxxxxxxx x  xxx  xxxxxxx x
x xx xxx xxxxxx      xxx xx x xx     xxx
xxxxxx xxx    x     xx xxxxxxxxx    xx x
x    xxx x   xx    xxxxx       x   xxxxx
x   xx xxx  xxx   xx   x      xx  xx   x
x  xxxxx x xx x  xxx  xx     xxx xxx  xx
x xx   xxxxxxxx xx x xxx    xx xxx x xxx
xxxx  xx      xxxxxxxx x   xxxxx xxxxx x


Create a new paste based on this one


Comments: