2021 - Day 6
🎄 Advent of Code in Zef 🎄​
https://adventofcode.com/2021/day/6
from zef import *
from zef.ops import *
c = collect
ages = [3,4,3,1,2]
def dict_step(d: dict) -> dict:
def num(n):
if n==8: return d.get(0,0)
elif n==6: return d.get(7,0) + d.get(0,0)
else: return d.get(n+1,0)
return {n: num(n) for n in range(9)}
result = (ages
| frequencies
| iterate[dict_step]
| nth[256]
| values
| sum
| collect
)