diff options
author | Tomasz Kramkowski <tk@the-tk.com> | 2021-12-06 12:25:42 +0000 |
---|---|---|
committer | Tomasz Kramkowski <tk@the-tk.com> | 2021-12-06 12:25:42 +0000 |
commit | 64ffb0abb536d21aa0225272d4faa22c2abf2070 (patch) | |
tree | c896e9fb7f00e3b751ea72ea6a83513ad95cdcae | |
parent | e400c1fab39d87c72f867007952ae3ef65823766 (diff) | |
download | aoc2021-64ffb0abb536d21aa0225272d4faa22c2abf2070.tar.gz aoc2021-64ffb0abb536d21aa0225272d4faa22c2abf2070.tar.xz aoc2021-64ffb0abb536d21aa0225272d4faa22c2abf2070.zip |
day 6: readd the dynamic programming solution
-rw-r--r-- | 6dp.py | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -0,0 +1,12 @@ +from functools import cache +from utils import open_day + +@cache +def count_fish(life): + if life <= 0: return 1 + return count_fish(life - 7) + count_fish(life - 9) + +fish = list(map(int, open_day(6).read().split(','))) + +print(sum(count_fish(80 - f) for f in fish)) +print(sum(count_fish(256 - f) for f in fish)) |