Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Moore Neighbourhood (old code) solution in Uncategorized category for Moore Neighbourhood by capback250
# migrated from python 2.7
COORDS = ((-1,-1), (-1, 0), (-1, 1),
(0, -1), (0, 1),
(1, -1), (1, 0), (1, 1))
def count_neighbours(grid, row, col):
i = 0
tp = list(map(list,list(zip(*grid))))
for c in COORDS:
x, y = row + c[0], col + c[1]
if x in range(len(tp[0])) and y in range(len(grid[0])):
i += grid[x][y]
return i
Feb. 9, 2016