Is the King In Check? (Part 2)
Difficulty : Medium
Community success rate: 85%
Approved by GeekNbOne an anonymous CodinGamer AkshatJ1127
A higher resolution is required to access the IDE
- 65
Learning Opportunities
This puzzle can be solved using the following concepts. Practice using these concepts and improve your skills.
Statement
Goal
Part 2 of a series, please solve Part 1 first to understand this problem fully https://www.codingame.com/training/easy/is-the-king-in-check-part-1The King will be a
Bishops (
Rooks (
Queens (
Knights (
Example 1
_ _ _ _ _ _ _ _
_ _ _ Q _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ N _ _ _ _
_ k _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
In the above diagram, the Queen is not able to attack the King, but the Knight is, so the repsonse is
Example 2
_ _ _ _ _ _ _ _
_ k N _ Q _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _
Here the Queen would be able to attack the King if it weren't for the fact that the Knight is in the way. The knight cannot attack the king either so the answer is
Input
8 lines of : 8 space-separated characters, mostly underscores with exactly one k and two of B /N /R /Q .
Output
1 line : Check if the King is in check (by either enemy) or No Check if not.
Constraints
Example
Input
_ _ _ _ _ _ _ Q _ _ _ _ R _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ k _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Output
Check
A higher resolution is required to access the IDE