Returns count of endless points
function countEndless ( input , n ) { let row = new Array ( n ) ; for ( let i = 0 ; i < n ; i ++ ) { row [ i ] = new Array ( n ) ; for ( let j = 0 ; j < n ; j ++ ) { row [ i ] [ j ] = false ; } } let col = new Array ( n ) ; for ( let i = 0 ; i < n ; i ++ ) { col [ i ] = new Array ( n ) ; for ( let j = 0 ; j < n ; j ++ ) { col [ i ] [ j ] = false ; } }