diff options
-rw-r--r-- | 4np.py | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -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) |