Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
pwnd solution in Clear category for Moore Neighbourhood by acilate
def count_neighbours(grid, row, col):
count = 0
for x in range ((row - 1), (row + 2)):
for y in range ((col - 1), (col + 2)):
if ((not x == row) or (not y == col)) \
and ((not x < 0) \
and (not y < 0) \
and (not x >= len(grid)) \
and (not y >= len(grid[x]))):
count += grid[x][y]
return count
March 14, 2015