24 lines
521 B
Python
24 lines
521 B
Python
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')
|
|
|
|
|