summaryrefslogtreecommitdiffstats
path: root/6np.py
blob: 6b97f9cf6194916dcdfff0915bf0946c5fc2dbc3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from collections import Counter
from utils import open_day
import numpy as np

fish = Counter(map(int, open_day(6).read().split(',')))

fish = np.array([fish[i] for i in range(9)])
mat = np.array([
    [0, 0, 0, 0, 0, 0, 1, 0, 1],
    [1, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 1, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 1, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 1, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 1, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 1, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 1, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 1, 0]
])

for i in range(256):
    if i == 80: print(sum(fish))
    fish = np.matmul(fish, mat)
print(sum(fish))