Checkmate! X11119


Statement
 

pdf   zip

Checkmate!

Please compute the minimum number of movements to checkmate the black king of a given (simplified) chess position, with the following properties:

  • It is white’s turn.

  • White has no king: only queens, rooks and bishops.

  • Black only has a king.

Input

Input consists of several cases. Each case begins with the position of the black king, followed by a number nn between 2 and 4, followed by the position of nn white pieces. Every given position is legal (except for the missing white king). It is always possible to checkmate the black king in at most 4 movements.

Output

For every position, print the minimum number of movements to checkmate the black king.

Author

Salvador Roura

© Jutge.org, 2006–2025.

Public test cases
  • Input

    Ka4 2 Rb7 Rg1
    Kh1 2 Qf8 Qe7
    Ka8 3 Ba7 Bb8 Bf1
    Ke3 3 Qd5 Rd4 Be5
    Kf1 3 Rd2 Be3 Re8
    Kd4 4 Ra5 Rh5 Bc8 Bf8
    

    Output

    1
    2
    1
    3
    2
    4
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Official solutions
    Unknown.
    User solutions