Skip to content

Instantly share code, notes, and snippets.

from scipy.signal import convolve2d
KERNEL = [[2, 2, 2],
[2, 1, 2],
[2, 2, 2]]
def iterate_grid(grid):
return abs(convolve2d(grid, KERNEL, mode='same') - 6) < 2