Is the King in Check?
Statement
Goal
Input is 8 rows of 8 space-separated characters representing a chessboard with only two pieces on the board: your King and some enemy piece. Print "The King will be a
Bishops (
Rooks (
Queens (
If a King is directly along any of the 'attack lines' of the enemy piece, then he is in check.
Print "B Check" if in check by a Bishop, "R Check" if in check by a rook, "Q Check" if in check by a Queen or "No Check" if the King is not in check.
Input
8 lines of : 8 space-separated characters, mostly underscores with exactly one K and one of B /R /Q .
Output
1 line : "X Check" if the King is in check (replacing 'X' with Q/B/R if in check by a Queen/Bishop/Rook) 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 /R /Q . Always an 8x8 size board, always two pieces.
Example
Input
_ _ R _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ K _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Output
R Check
Game modes
Fastest, Shortest
Test cases
R vs K Test
Input
_ _ R _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ K _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
Output
R 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
B Check
Q vs K Test
Input
Q _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ K _
_ _ _ _ _ _ _ _
Output
Q Check
Validator 3 Validator
Input
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ K _ _ _ _
_ _ _ _ _ _ _ _
_ _ Q _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
Output
No Check
K vs R Test
Input
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ K _ _ _ _
_ _ _ _ R _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
Output
No Check
Validator 4 Validator
Input
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ K _ _ _ R
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
Output
R Check
K vs B Test
Input
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
B _ _ _ _ _ _ _
_ K _ _ _ _ _ _
Output
B Check
Validator 5 Validator
Input
_ _ _ _ _ _ _ Q
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ K
Output
Q Check
Solution language
Solution
Stub generator input