Last active
December 6, 2015 14:23
-
-
Save thomasruiz/d24987734c5abde3ce86 to your computer and use it in GitHub Desktop.
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 | |
$l = str_repeat('0', 1000000); | |
$i = file('i'); | |
foreach ($i as $s) { | |
$tok = strtok($s, ' '); | |
$instruction = 1; | |
$c = ''; | |
if ($tok === 'toggle') { | |
$instruction = 0; | |
} else { | |
if (strtok(' ') === 'on') { | |
$c = '1'; | |
} else { | |
$c = '0'; | |
} | |
} | |
$x = strtok(','); | |
$y = strtok(' '); | |
strtok(' '); | |
$d = strtok(','); | |
$e = strtok("\n"); | |
while ($x <= $d) { | |
$z = $y; | |
while ($z <= $e) { | |
$a = $l[$x + $z * 1000]; | |
if ($instruction === 0) { | |
$c = $a === '1' ? '0' : '1'; | |
} | |
$l[$x + $z * 1000] = $c; | |
$z += 1; | |
} | |
$x += 1; | |
} | |
} | |
echo substr_count($l, '1'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment