Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Second solution in Clear category for Moore Neighbourhood by eugene100372
def count_neighbours(grid, row, col):
return (sum(sum(((0,)+(((),)+grid+((),))[row+i])[col:col+3]) for i in (0,1,2))
-grid[row][col])
Sept. 14, 2020