Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Moore Neibhbourhood solution in Clear category for [old] Moore Neighbourhood by capback250
"use strict";
function countNeighbours(data, row, col) {
var neibors = 0;
var cors = [
[-1, -1], [-1, 0], [-1, 1],
[ 0, -1], [ 0, 1],
[ 1, -1], [ 1, 0], [ 1, 1]
];
var xsize = data.length, ysize = data[0].length;
cors.forEach(function (element) {
var dx = element[0] + row, dy = element[1] + col;
if ((0 <= dx && dx < xsize) && (0 <= dy && dy < ysize) && data[dx][dy]) {
neibors++;
}
});
return neibors;
}
Sept. 18, 2016
Comments: