AdventOfCode/2021/day6/day6_part1.py

24 lines
521 B
Python
Raw Normal View History

2023-12-09 22:01:20 +01:00
import sys
f = open(sys.argv[1],"r")
for line in f:
line = line.strip().split(',')
line = [int(i) for i in line]
print("Initial state: " + str(line))
days = 80
for i in range(1,days+1):
for j in range(0,len(line)):
if line[j] == 0:
line[j] = 6
line.append(8)
elif line[j] >= 1 and line[j] <= 8:
line[j] -= 1
#print("After " + str(i).zfill(2) + " days: " + str(line))
print('After ' + str(days) + ' days there are ' + str(len(line)) + ' lanternfish')