diff options
author | Tomasz Kramkowski <tk@the-tk.com> | 2021-12-06 08:40:31 +0000 |
---|---|---|
committer | Tomasz Kramkowski <tk@the-tk.com> | 2021-12-06 08:40:31 +0000 |
commit | 36bd3e75b10a4cfa333815170044f54c41487ab5 (patch) | |
tree | 04f89f975e9527e5e209f9f681752849d0f95e2b | |
parent | 7f4b9b1dd4da3d9ce04d068b5600e00e278939a6 (diff) | |
download | aoc2021-36bd3e75b10a4cfa333815170044f54c41487ab5.tar.gz aoc2021-36bd3e75b10a4cfa333815170044f54c41487ab5.tar.xz aoc2021-36bd3e75b10a4cfa333815170044f54c41487ab5.zip |
day 6: numpy
-rw-r--r-- | 6np.py | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -0,0 +1,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)) |