aoc2021/d06/d06_2.py

10 lines
250 B
Python

import sys
D ={ i:0 for i in range(9) }
for l in list(map(int,sys.stdin.read().split(","))):
D[l]+=1
for i in range(int(sys.argv[1])): # 80 then 256
D = { i-1:D[i] for i in range(9) }
D[6] += D[-1]
D[8] = D[-1]
print(sum(D[i] for i in range(9)))