Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Simple Math solution in Clear category for Moore Neighbourhood by developingcoder
def count_neighbours(grid, row, col):
count = 0
for i, r in enumerate(grid):
for j, v in enumerate(r):
if max(abs(row - i), abs(col - j)) == 1:
count += v
return count
May 22, 2016
Comments: