Last active
August 29, 2015 14:11
-
-
Save greydnls/11b06dd4077aee368d3a to your computer and use it in GitHub Desktop.
Rule 30
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$lines = array(); | |
$first_line = array_fill(0, 51, '*'); | |
$first_line[24] = '/'; | |
$lines[] = $first_line; | |
$rules = array( | |
'///'=> '*', | |
'//*' => '*', | |
'/*/'=> '*', | |
'/**' =>'/', | |
'*//'=> '/', | |
'*/*' => '/', | |
'**/'=> '/', | |
'***' => '*' | |
); | |
for ($i = 0; $i< 10; $i++) | |
{ | |
$line = array(); | |
for($j = 0; $j< 51; $j++) | |
{ | |
$pattern = (string)implode('', array_slice(end($lines), $j - 1, 3)); | |
$value = (strlen($pattern) == 3 && isset($rules[$pattern])) ? $rules[$pattern] : '*'; | |
$line[] = $value; | |
} | |
$lines[] = $line; | |
} | |
foreach ($lines as $line) | |
{ | |
foreach ($line as $piece) | |
{ | |
echo $piece; | |
} | |
echo "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment