0
How to solve it?
You have to find either a chess figure can eat another one. Input the name and the coordinates of one of the following figures: 1. rook 2. bishop 3. knight Then input coordinates of figure to eat. Show YES if it can it and NO otherwise. It is considered that only two figures on a chess table. See the picture below. Example: Input: rook 4 b 7 b Output: YES Example: Input: bishop 2 e 3 b Output: NO
1 Réponse
+ 3
Start by getting and parsing the input. You can use an if-statement to distinguish between the pieces.
Rook: If the file or the rank matches, the rook will be able to capture.
Bishop: When the absolute difference of ranks is the same as the absolute difference of the files, the pieces are aligned on a diagonal and the bishop can capture.
Knight: Similar to Bishop, but you need to check for a (2, 1) or (1, 2) pattern in absolute difference.
Try implementing this and see how far you can get without help. Feel free to post the code if you are having trouble.
By the way, there is no picture attached as stated in the description, just for notice.
Captures captures!