You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
827 B
37 lines
827 B
import os
|
|
|
|
def tick(currentLanturnFish):
|
|
new_fish_to_spawn = 0
|
|
|
|
for i in range(len(currentLanturnFish)):
|
|
fish = currentLanturnFish[i]
|
|
fish = fish - 1
|
|
|
|
if fish < 0:
|
|
new_fish_to_spawn = new_fish_to_spawn + 1
|
|
fish = 6
|
|
|
|
currentLanturnFish[i] = fish
|
|
for x in range(new_fish_to_spawn):
|
|
currentLanturnFish.append(8)
|
|
|
|
return currentLanturnFish
|
|
|
|
dir = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
with open(os.path.join(dir, './input.txt'), 'r') as input_file:
|
|
|
|
lines = input_file.readlines()
|
|
|
|
line = lines[0].strip()
|
|
parts = line.split(',')
|
|
|
|
fish = []
|
|
for part in parts:
|
|
fish.append(int(part))
|
|
|
|
days_to_predict = 80
|
|
for x in range(days_to_predict):
|
|
#print(fish)
|
|
fish = tick(fish)
|
|
print(len(fish))
|