]> git.friedersdorff.com Git - max/advent_of_code_2021.git/blob - 6_2.py
Try day 14
[max/advent_of_code_2021.git] / 6_2.py
1 """Simulate unreasonably many lanternfish pop growth"""
2
3 fishes = {x: 0 for x in range(9)}
4
5 with open("6_input.txt") as f:
6     for age in [int(x) for x in f.read().split(",")]:
7         fishes[age] += 1
8
9 for day in range(100000):
10     print(day)
11     next_day_fishes = {x: 0 for x in range(9)}
12     next_day_fishes[8] = fishes[0]
13     next_day_fishes[6] = fishes[0]
14
15     for i in range(8):
16         next_day_fishes[i] += fishes[i+1]
17
18     fishes = next_day_fishes
19
20 print(fishes)
21 print(sum(fishes.values()))