Zig-zag matrix: Difference between revisions

m
Line 1,707:
) : [];
}
 
// Recursively read off n heads from the diagonals (as rows)
// [[n]] -> [[n]]
Line 1,717:
return x[0];
})].concat(
nHeads(n, [].concat.apply([], lstFirst.map(function (x) {
functionreturn (x.length > 1 ? [x.slice(1)] : {[];
return x})).length > 1 ? [xconcat(lst.slice(1n)))] : [];
}
)).concat(lst.slice(n)))
);
}
Line 1,733 ⟶ 1,731:
 
// Recursively take n heads from the alternately reversed diagonals
return nHeads(n, diagonals(n, 1, range(0, (n * n) - 1)).map(function (x, i) {
functionif (x, !(i % 2)) {
if x.reverse(!(i % 2)) {;
}
x.reverse();
return }x;
}));
return x;
 
}));
})(5);</lang>
 
9,655

edits