Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for [old] Moore Neighbourhood by mozurin
"use strict";
function countNeighbours(data, row, col)
{
return [-1, 0, 1].reduce(
(s, dr) => s + [-1, 0, 1].reduce(
(s, dc) => s + (
(dr || dc) && (
data[row + dr]? data[row + dr][col + dc] || 0 : 0
)
),
0
),
0
);
}
June 24, 2018
Comments: