Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
clean and clear using vigesimal coordinates solution in Clear category for [old] Chess Knight by vincent.tscherter
function chessKnight(start, moves) {
let createMoves = pos => [-18, 22, 41, 39, 18, -22, -41, -39]
.map(p => (parseInt(pos, 20) + p).toString(20))
.filter(p => p.match(/[a-h][1-8]/));
let out = createMoves(start);
while(--moves) out = out.reduce((accu, pos) =>
accu.concat(createMoves(pos)), out )
.filter((x, i, a) => a.indexOf(x) == i);
return out.sort(), out;
}
May 24, 2018