19 lines
458 B
PHP
19 lines
458 B
PHP
|
<?php
|
||
|
|
||
|
$timers = explode(',', file_get_contents('./input.txt'));
|
||
|
|
||
|
echo sprintf('Initial state: %s', implode(',', $timers));
|
||
|
|
||
|
for ($i = 0; $i < 80; $i++) {
|
||
|
for($t = 0, $l = count($timers); $t < $l; $t++) {
|
||
|
if ($timers[$t] > 0) {
|
||
|
$timers[$t]--;
|
||
|
} else {
|
||
|
$timers[$t] = 6;
|
||
|
$timers[] = 8;
|
||
|
}
|
||
|
}
|
||
|
echo sprintf('After %u day(s): %s%s', $i + 1, implode(',',$timers), "\n");
|
||
|
}
|
||
|
|
||
|
echo count($timers);
|