Fairy Knight Moves

A challenge by mousetail avatar mousetail

Description

Given a knight move (long axis distance, short axis distance), output how many steps it would take to each each position on a standard 8 by 8 chess board, starting at the top left corner.

For example, if the input is 2,1 you might output:

 0  3  2  3  2  3  4  5
 3  4  1  2  3  4  3  4
 2  1  4  3  2  3  4  5
 3  2  3  2  3  4  3  4
 2  3  2  3  4  3  4  5
 3  4  3  4  3  4  5  4
 4  3  4  3  4  5  4  5
 5  4  5  4  5  4  5  6

Each number is padded to two digits with a space, and there is a space between each cell. If a tile is entirely unreachable, print --. For example, if the input was 1,1 you would output:

 0 --  2 --  4 --  6 --
--  1 --  3 --  5 --  7
 2 --  2 --  4 --  6 --
--  3 --  3 --  5 --  7
 4 --  4 --  4 --  6 --
--  5 --  5 --  5 --  7
 6 --  6 --  6 --  6 --
--  7 --  7 --  7 --  7

There is one input in each line, separate each output with a blank line.

Leaderboard

Author bytes
#1 bizy-coder avatar bizy-coder 213