Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Moore Neighbourhood by nbisco
def count_neighbours(grid, row, col):
rsize = len(grid)
csize = len(grid[0])
ans = 0
for r in (-1,0,1,):
for c in (-1,0,1,):
if r==0 and c==0:
continue
elif ((row+r)>=0 and (row+r)=0 and (col+c)
Jan. 25, 2015