~/algor $ cat problems/dona-yurishi
One move for the piece?
One piece stands on an empty chessboard. The letter of the piece and two squares are given: the square the piece is on and the square it must reach (for example, e2: the letter is the column a…h, the digit is the row 1…8). Can the piece reach that square in one move? K (king) moves to a neighbouring square (side by side or diagonally); R (rook) — to any square of the same row or column; B (bishop) — along a diagonal; Q (queen) — like a rook or a bishop; N (knight) — in an "L" shape: $2$ squares in one direction and $1$ square in the other. Print YES if it can, otherwise NO.
Input
One line: the letter of the piece and two squares — where the piece stands and where it must go.
Output
YES or NO.
Note
The letter is only K, Q, R, B or N.
Both squares are on the board and different.
Examples
N g1 f3
YES
B c1 h7
NO