38. Chess Check

Snow had closed the roads to Dorpat that week, and the university common room filled with restless students seeking occupation for their minds.

A chessboard stood near the tiled stove, its pieces worn smooth by many winters. Johann leaned over it like a general before battle.

„Observe carefully,“ he announced. „You are about to witness the fall of an empire.“

His opponent said nothing. A knight moved.

„Checkmate.“

Johann stared at the board. The crooked path of the knight was suddenly obvious to everyone except the man who had just declared victory.

Laughter spread through the room.

„Chess has too many possibilities,“ Johann protested. „No one can see every threat.“

„Nonsense.“

Professor Reichenstein stood in the doorway, hands folded behind his back.

„Every piece moves by rule. Determining whether a king is threatened requires no imagination— only inspection.“

His eyes rested briefly on Mihkel.

„A mechanical mind should find it trivial.“

Johann smirked. „There you have it, Mihkel. A royal investigation.“

Mihkel looked at the board. Beneath the carved crowns and bishops there was nothing mystical. Only distance. Direction. Rule.

That night he prepared a short strip of tape in the quiet of his workshop. The king’s square. The opposing piece. Two positions on a board of sixty-four possibilities. The Logic Mill stirred.

A rook demanded alignment. A bishop required the truth of a diagonal. A knight ignored the path entirely and arrived by angle alone. The Mill tested each rule in silence, asking only one question:

Can the piece reach the king?

The mechanism slowed, then stopped.

On the input tape, you’ll get the positions of a black king and a white piece (separated by a comma). Your task is to determine whether the black king is in check, and output Y if it is, or N otherwise.

The board contains only these two pieces. The white piece may be a queen, rook, bishop, or knight.

The positions are given in the following chess notation:

  1. The first character denotes the piece type: Queen, Rook, Bishop, Nnight, or King (only for black).
  2. The second character is a letter from a to h, denoting the file.
  3. The third character is a digit from 1 to 8, denoting the rank.

For example, if the input is Kb4,Nd5, the output should be Y because the knight on d5 attacks the king on b4 (see the board).

Sign in to submit your solution.

Quest leaderboard
Discuss it on Reddit or Discord
This was the last quest for now.
Get updates about new quests by subscribing to the social media channels or RSS