-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path06a.py
More file actions
37 lines (26 loc) · 715 Bytes
/
06a.py
File metadata and controls
37 lines (26 loc) · 715 Bytes
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
#!/usr/bin/env python3
import numpy as np
class Fish():
def __init__(self, t):
self.t = int(t)
def __repr__(self):
return "f{0}".format(self.t)
def __str__(self):
return "f{0}".format(self.t)
def next(self):
self.t -= 1
if self.t < 0:
self.t = 6
return Fish(8)
return
with open('06.input', 'r') as f:
fishs = [Fish(f) for f in f.readline().split(',')]
new_fish = []
for i in range(80):
for f in fishs:
n = f.next()
if n is not None:
new_fish.append(n)
fishs.extend(new_fish)
new_fish = []
print(len(fishs) + len(new_fish))