aoc/2021/06/06.py
2021-12-06 20:54:30 -06:00

30 lines
503 B
Python

with open("sample.txt") as f:
fish = [int(n) for n in f.read().split(',')]
def advance(fish):
tomorrow = []
spawn = 0
for f in fish:
if f == 0:
tomorrow.append(6)
spawn += 1
else:
tomorrow.append(f-1)
for i in range(spawn):
tomorrow.append(8)
return tomorrow
def part1(fish):
for i in range(80):
fish = advance(fish)
return len(fish)
print(part1(fish))
## TOO LONG
# def part2(fish):
# for i in range(256):
# fish = advance(fish)
# return len(fish)
# print(part2(fish))