summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--4np.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/4np.py b/4np.py
index ad04746..1af238e 100644
--- a/4np.py
+++ b/4np.py
@@ -1,13 +1,13 @@
import numpy as np
from utils import open_day
-BOARD_SIZE = 5
-
nums, boards = open_day(4).read().rstrip().split('\n\n', maxsplit=1)
nums = np.fromstring(nums, sep=',', dtype=int)
numidxs = np.empty(nums.size, dtype=int)
numidxs[nums] = np.arange(nums.size)
-boards = np.fromstring(boards.replace('\n', ' '), sep=' ', dtype=int).reshape(-1, BOARD_SIZE, BOARD_SIZE)
+board, _ = boards.split('\n\n', maxsplit=1)
+board = [list(row.split()) for row in board.split('\n')]
+boards = np.fromstring(boards.replace('\n', ' '), sep=' ', dtype=int).reshape(-1, len(board), len(board[0]))
rboards = numidxs[boards]
colmins = np.amin(np.amax(rboards, axis=1), axis=1)
rowmins = np.amin(np.amax(rboards, axis=2), axis=1)