Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Simple, clear solution solution in Clear category for Moore Neighbourhood by dunpealer
def count_neighbours(grid, row, col):
count = -grid[row][col]
for r in range(max(row-1, 0), min(row+2, len(grid))):
for c in range(max(col-1, 0), min(col+2, len(grid[0]))):
count += grid[r][c]
return count
Aug. 15, 2015
Comments: