summaryrefslogtreecommitdiffstats
path: root/6.py
diff options
context:
space:
mode:
Diffstat (limited to '6.py')
-rw-r--r--6.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/6.py b/6.py
new file mode 100644
index 0000000..4e1e127
--- /dev/null
+++ b/6.py
@@ -0,0 +1,16 @@
+from functools import cache
+from utils import open_day
+
+fish = list(map(int, open_day(6).read().split(',')))
+
+@cache
+def count_fish(n, life):
+ if life < 0:
+ return 1
+ if n == 0:
+ return count_fish(0, life - 7) + count_fish(2, life - 7)
+ else:
+ return count_fish(0, life - n)
+
+print(sum(count_fish(f, 79) for f in fish))
+print(sum(count_fish(f, 255) for f in fish))