diff --git a/day_6/part_1.php b/day_6/part_1.php new file mode 100644 index 0000000..8c7c95d --- /dev/null +++ b/day_6/part_1.php @@ -0,0 +1,19 @@ + 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); \ No newline at end of file diff --git a/day_6/part_2.php b/day_6/part_2.php new file mode 100644 index 0000000..15d821a --- /dev/null +++ b/day_6/part_2.php @@ -0,0 +1,24 @@ + $count) { + if($number > 0) { + $tmp[$number-1] += $count; + } else { + $tmp[6] += $count; + $tmp[8] += $count; + } + } + $timers = $tmp; + + echo sprintf('After %u day(s): %s with %u zero%s', $i + 1, array_sum($timers), (array_key_exists(0, $timers) ? $timers[0] : 0), "\n"); +} + +echo array_sum($timers); \ No newline at end of file