From 64ffb0abb536d21aa0225272d4faa22c2abf2070 Mon Sep 17 00:00:00 2001 From: Tomasz Kramkowski Date: Mon, 6 Dec 2021 12:25:42 +0000 Subject: day 6: readd the dynamic programming solution --- 6dp.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 6dp.py diff --git a/6dp.py b/6dp.py new file mode 100644 index 0000000..3e6ad59 --- /dev/null +++ b/6dp.py @@ -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)) -- cgit v1.2.3-54-g00ecf