diff --git a/day17/part1.py b/day17/part1.py index 631c9a2..f35dcc4 100644 --- a/day17/part1.py +++ b/day17/part1.py @@ -13,12 +13,12 @@ kernel[(1, )*DIMS] = 0 for _ in range(6): grid = np.pad(grid, pad_width=1) - neighbors = convolve(grid, kernel, mode='same') + neighbors = convolve(grid, kernel, mode='same', method='direct') set_inactive = np.logical_and(grid == 1, np.floor_divide(neighbors, 2) != 1) set_active = np.logical_and(grid == 0, neighbors == 3) grid[set_inactive] = 0 grid[set_active] = 1 - a = tuple(slice(np.min(idxs), np.max(idxs) + 1) for idxs in np.where(grid == 0)) + a = tuple(slice(np.min(idxs), np.max(idxs) + 1) for idxs in np.where(grid == 1)) grid = grid[a] print(np.sum(grid)) diff --git a/day17/part2.py b/day17/part2.py index 44fb3bd..b52a745 100644 --- a/day17/part2.py +++ b/day17/part2.py @@ -13,12 +13,12 @@ kernel[(1, )*DIMS] = 0 for _ in range(6): grid = np.pad(grid, pad_width=1) - neighbors = convolve(grid, kernel, mode='same') + neighbors = convolve(grid, kernel, mode='same', method='direct') set_inactive = np.logical_and(grid == 1, np.floor_divide(neighbors, 2) != 1) set_active = np.logical_and(grid == 0, neighbors == 3) grid[set_inactive] = 0 grid[set_active] = 1 - a = tuple(slice(np.min(idxs), np.max(idxs) + 1) for idxs in np.where(grid == 0)) + a = tuple(slice(np.min(idxs), np.max(idxs) + 1) for idxs in np.where(grid == 1)) grid = grid[a] print(np.sum(grid))