Author: Eamon Caddigan <email@example.com>
Date: Mon, 6 Dec 2021 11:40:25 -0500
Solution to day 6, part 2
1 file changed, 35 insertions(+), 0 deletions(-)
diff --git a/day06_part2.py b/day06_part2.py
@@ -0,0 +1,35 @@
+"""Advent of Code 2021, day 6 (part 2): simulate an exponentially growing
+school of lanternfish using an initial list of fish and their ages... for a
+longer period than part 1"""
+# I find myself metagaming a little bit: anticipating how part 2 will build
+# upon part 1, while trying to make it easy to accommodate in my existing code
+# without over-engineering things for functionality that won't become
+# necessary. IME, this is what being a programmer (including 'data scientist')
+# in the real world is actually like.
+# In this case, I was imagining something more complicated, like: maybe there
+# are a couple different types of fish, or maybe the fish die eventually, or
+# maybe the spawn rate depends on the size of the school. But instead we're
+# doing something dead simple: running the same solution as before, but for
+# longer. I suspect that this is supposed to punish people who
+# implemented a list of fish instead of a set of counts.
+from day06_part1 import (convert_input_to_series,
+from utils import get_puzzle_input
+ """Return the numeric solution to the puzzle"""
+ return count_fish_after(convert_input_to_series(input_string), 256)
+ """Run when the file is called as a script"""
+ assert solve_puzzle("3,4,3,1,2\n") == 26984457539
+ print("Number of lanternfish after 256 days:",
+if __name__ == "__main__":
+ import sys