Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for [old] Radiation Search by capback250
"use strict";
const SIDES = [[-1, 0], [0, -1], [1, 0], [0, 1]];
function radiationSearch(data) {
let union = [];
let size = data.length;
const numIndexFinder = (number) => {
for (let i =0; i< size; i++) {
for (let j=0; j {
return SIDES
.map(el => [el[0] + index[0], el[1] + index[1]])
.filter(pairs => pairs.every(el => el >= 0 && el < size))
.filter(el => data[el[0]][el[1]] === number)
};
for (let num = 1 ; num <= 5; num++) {
while(numIndexFinder(num)){
let que = [numIndexFinder(num)];
for (let node of que){
data[node[0]][node[1]] = 0;
neiborsFinder(node, num).map(el=>{
if(!que.filter(qEl => qEl[0] === el[0] && qEl[1] === el[1]).length){
que.push(el);
}
})
}
union.push([que.length, num])
}
}
return union.sort((a, b) => b[0] - a[0])[0]
}
April 27, 2017