Jack and Jane decided to play a game of chess to while away time. Unfortunately, Jack is rather bad at visualizing. He finds it tough to figure the moves possible for a given piece other than a pawn, of course!
Your challenge is to help find Jack the possible options for a given piece (other than a pawn).
In case one has forgotten, the various pieces are denoted by:
- K: King
- Q: Queen
- N: Knight
- B: Bishop
- R: Rook
As an example, in the following image the Knight is located at
d4 and can move to
e2. For a given input:
you would produce:
Nc2 Nb3 Nb5 Nc6 Ne6 Nf5 Nf3 Ne2
- The order of the output doesn't matter as long as all the possible moves are listed
- The possible moves can be separated by whitespaces, newlines or any other delimiter
- The input can be passed to the program as a parameter or via
- Whitespace in the program shall be counted, so make optimum use of it
This is code golf. (Please avoid making use of any tools/utilities specifically designed for the purpose.) The shortest answer wins!