codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
<?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(); ?>
Private
[
?
]
Run code
Submit