Created
March 6, 2019 20:20
-
-
Save koalatux/af66c8e370ce0f1b8ec6d0bb3372fde1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
input_grid = [[False, True, False, False], | |
[False, False, True, False], | |
[True, True, True, False], | |
[False, False, False, False]] | |
print(iterate_grid(input_grid)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment