From 36bd3e75b10a4cfa333815170044f54c41487ab5 Mon Sep 17 00:00:00 2001 From: Tomasz Kramkowski Date: Mon, 6 Dec 2021 08:40:31 +0000 Subject: day 6: numpy --- 6np.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 6np.py diff --git a/6np.py b/6np.py new file mode 100644 index 0000000..6b97f9c --- /dev/null +++ b/6np.py @@ -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)) -- cgit v1.2.3-54-g00ecf