This is Hole-3 from The Autumn Tournament of APL CodeGolf. I am the original author of the problem there, and thus allowed to re-post it here.
Given:
a number of turns (please state if no movements is 0, otherwise we'll assume it is called 1) and
a list of one or more starting positions (in any form, e.g. 0 or 1 indexed coordinates or 64 consecutive numbers/characters or A1–H8 – state which), on an 8-by-8 chessboard,
return (in any order) the list of unique positions (in the same format as the input) that knight(s) can be at after the given number of turns.
Each knight must move with every turn, but you do not have to worry about multiple knights occupying the same square.
A knight can only move to the positions marked with X relative to its current position, marked with ♞:
Examples (1-indexed coordinates)
1
move from [[1,1]]
: [[2,3],[3,2]]
2
moves from [[1,1]]
: [[1,1],[1,3],[1,5],[2,4],[3,1],[3,5],[4,2],[4,4],[5,1],[5,3]]
1
move from [[1,1],[5,7]]
: [[2,3],[3,2],[3,6],[3,8],[4,5],[6,5],[7,6],[7,8]]
2
moves from [[1,1],[5,7]]
: [[1,1],[1,3],[1,5],[1,7],[2,4],[2,6],[2,8],[3,1],[3,3],[3,5],[3,7],[4,2],[4,4],[4,6],[4,8],[5,1],[5,3],[5,5],[5,7],[6,4],[6,6],[6,8],[7,3],[7,7],[8,4],[8,6],[8,8]]
0
moves from [[3,4]]
: [[3,4]]
[[1,1]], 2 -> [[2,3],[3,2]]
\$\endgroup\$