For this challenge, you will be writing a program or function which outputs (or prints) (in a reasonable format, i.e single string or an array of lines) a chess board indicate all the possible moves of a piece given an empty board.
There are 5 chess pieces (for this challenge a pawn may be ignored)
- Bishop (moves diagonally any number of squares)
- Rook (Moves orthogonally any number of squares)
- Queen (Moves diagonally or orthogonally any number of squares)
- KNight (moves in an L shape two in one dimension, and one in the other)
- King (Moves one step orthogonally or diagonally)
Your submission will take in three inputs. The row of the chess piece, the column of the chess piece and the type of piece (as a character or integer).
Say we call drawBoard(4,4,'N') output as follows
........
........
...M.M..
..M...M.
....N...
..M...M.
...M.M..
........
where the '.' and 'M' can be replaced accordingly with printable ascii characters of your choice Sample outputs as follows for other piece types. (Note all of these are called with input of 4,4 (zero indexed).
King:
........
........
........
...mmm..
...mKm..
...mmm..
........
........
Rook:
....m...
....m...
....m...
....m...
mmmmRmmm
....m...
....m...
....m...
Sam does not mind 1 based indexing, or even indexing follow chess algebraic notation. However, your code must be as small as possible so Sam has enough space to think about his chess with the code next to him.
Sam has also realized that outputs will be accpeted regardless of trailing or preceding whitespace (before and after input and each line)
o
s to.
s, or changing them to spaces and adding a border. It's kinda unreadable at the moment. \$\endgroup\$ – El'endia Starman Aug 10 '16 at 20:46