#C5942. Valid Chess Move Checker
Valid Chess Move Checker
Valid Chess Move Checker
This problem involves checking whether a given chess piece can legally move from a starting position to a target position on a standard 8×8 chessboard. The positions are provided in standard chess notation (e.g., A1, H8). You need to consider the move rules for the following pieces: King, Queen, Rook, Bishop, Knight, and Pawn.
For the Pawn, note that it may move two squares forward if it is in its initial position (i.e., on the second rank), otherwise it moves one square forward. All moves must also follow the standard movement rules of chess.
Your program should read the input from standard input (stdin) and output the result to standard output (stdout). The output should be YES
if the move is valid according to the chess rules, and NO
otherwise.
inputFormat
The input consists of three lines:
- The first line contains the chess piece type as a string (one of "King", "Queen", "Rook", "Bishop", "Knight", "Pawn").
- The second line contains the starting position in standard chess notation (e.g., "E2").
- The third line contains the target position in standard chess notation (e.g., "E3").
outputFormat
The output is a single line, printed to stdout, containing either "YES" if the move is valid, or "NO" if it is not.
## sampleKing
E2
E3
YES
</p>