Is the King In Check? (Part 1)
Statement
Goal
8 x 8 space-separated character rows of a chessboard with only two pieces on the board. Your King and some enemy piece. Print "Check" or "No Check" depending on whether the enemy piece is able to attack your king on the next turn.The King will be a
Bishops (
Rooks (
Queens (
Knights (
Diagram for the squares a Knight can attack (NB: x is used here to indicate these squares, will never be in the game input):
_ _ _ _ _ _ _ _
_ _ x _ x _ _ _
_ x _ _ _ x _ _
_ _ _ N _ _ _ _
_ x _ _ _ x _ _
_ _ x _ x _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
If a King is in any of those x positions relative to the Knight on the input diagram, then the answer is "Check", otherwise "No Check".
Input
8 lines of : 8 space-separated characters, mostly underscores with exactly one K and one of B /N /R /Q .
Output
1 line : "Check" if the King is in check or "No Check" if not.
Constraints
Only two pieces on the board. Only non-space characters in input are _ , one K and one of B /N /R /Q . Always an 8x8 size board, always two pieces.
Example
Input
_ _ R _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ K _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Output
Check
Tags
Chess, Grid, Conditions
Difficulty
Easy
Test cases
R vs K Test
Input
_ _ R _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ K _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
Output
Check
Validator 1 Validator
Input
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ K _ _ _
_ _ _ _ _ R _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
Output
No Check
B vs K Test
Input
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ K _ _ _ _ _
_ _ B _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
Output
No Check
Validator 2 Validator
Input
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
K _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ B _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
Output
Check
Q vs K Test
Input
Q _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ K _
_ _ _ _ _ _ _ _
Output
Check
Validator 3 Validator
Input
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ K _ _ _ _
_ _ _ _ _ _ _ _
_ _ Q _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
Output
No Check
N vs K Test
Input
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ N _ K _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
Output
No Check
Validator 4 Validator
Input
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ K _ _ _
_ _ _ _ _ _ _ _
_ _ _ N _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
Output
Check
Test 5 Test
Input
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ N _ _
_ _ _ _ _ _ _ K
Output
Check
Validator 5 Validator
Input
_ _ _ _ _ _ _ Q
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ K
Output
Check
Solution language
Solution
Stub generator input