2021 day6/python: add solution
This commit is contained in:
parent
75d4a76a50
commit
7f42d47cae
1 changed files with 20 additions and 0 deletions
20
2021/day6/day6.py
Executable file
20
2021/day6/day6.py
Executable file
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import functools
|
||||
|
||||
@functools.cache
|
||||
def spawns(days):
|
||||
acc = days//7
|
||||
days -= 9
|
||||
acc += sum(spawns(days-x*7) for x in range(days//7))
|
||||
return acc
|
||||
|
||||
if __name__ == '__main__':
|
||||
inp = [int(i) for i in sys.stdin.readline().split(',')]
|
||||
|
||||
def do(days):
|
||||
spawns.cache_clear()
|
||||
return sum(1 + spawns(days + (6 - fish)) for fish in inp)
|
||||
print(do(80))
|
||||
print(do(256))
|
Loading…
Reference in a new issue