Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
lambda solution in Clear category for Moore Neighbourhood by Phil15
from itertools import product as prod
count_neighbours = lambda G,r,c: sum(G[r+i][c+j]
for i,j in set(prod(*[(-1,0,1)]*2))-{(0,0)}
if 0<=r+i
Oct. 10, 2018
Comments: