-
Notifications
You must be signed in to change notification settings - Fork 1
/
part1.py
36 lines (27 loc) · 1.44 KB
/
part1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
class Lanternfish:
def __init__(self, days=9):
self.days = days
def reset(self):
self.days = 6
def cycle(self):
self.days -= 1
if self.days < 0:
self.reset()
def main():
test_input = "3,4,3,1,2"
live_input = "1,2,1,1,1,1,1,1,2,1,3,1,1,1,1,3,1,1,1,5,1,1,1,4,5,1,1,1,3,4,1,1,1,1,1,1,1,5,1,4,1,1,1,1,1,1,1,5,1,3,1,3,1,1,1,5,1,1,1,1,1,5,4,1,2,4,4,1,1,1,1,1,5,1,1,1,1,1,5,4,3,1,1,1,1,1,1,1,5,1,3,1,4,1,1,3,1,1,1,1,1,1,2,1,4,1,3,1,1,1,1,1,5,1,1,1,2,1,1,1,1,2,1,1,1,1,4,1,3,1,1,1,1,1,1,1,1,5,1,1,4,1,1,1,1,1,3,1,3,3,1,1,1,2,1,1,1,1,1,1,1,1,1,5,1,1,1,1,5,1,1,1,1,2,1,1,1,4,1,1,1,2,3,1,1,1,1,1,1,1,1,2,1,1,1,2,3,1,2,1,1,5,4,1,1,2,1,1,1,3,1,4,1,1,1,1,3,1,2,5,1,1,1,5,1,1,1,1,1,4,1,1,4,1,1,1,2,2,2,2,4,3,1,1,3,1,1,1,1,1,1,2,2,1,1,4,2,1,4,1,1,1,1,1,5,1,1,4,2,1,1,2,5,4,2,1,1,1,1,4,2,3,5,2,1,5,1,3,1,1,5,1,1,4,5,1,1,1,1,4"
lanternfishes = [Lanternfish(int(l)) for l in test_input.split(',')]
for i in range(1, 257):
if i%50 == 0 :
print(i)
for lanternfish in lanternfishes:
if lanternfish.days == 0:
lanternfishes.append(Lanternfish())
lanternfish.cycle()
#output = ""
# for lanternfish in lanternfishes:
# output += '{},'.format(lanternfish.days)
#print('After {} day:'.format(str(i).rjust(2)), output[:-1])
print('Total of {} fish'.format(len(lanternfishes)) )
if __name__ == '__main__':
main()