blob: 4e1e12749e25649c68e8b5576836b60dea2be30b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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))
|