Dead Or Not – That Is The Question
On a standard checkerboard (8 × 8 squares) the only black piece is the king. The only limitation to the number and kind of white pieces is the number of squares left (63). This means that apart from the black king there can be between zero and 63 white pieces on the board.
Your objective is to determine whether the black king is under check and cannot move to the square which is not attacked (checkmate) or is not under check but there is no square to go which is not attacked (draw) or there exists a square where it can move (game is not over).
Input
Input consists of several lines. Each line of the input file contains the description of the boards state is a 64-character string with each character representing a square on the board (row after row). The black king will always present in this string. The white king will never be the neighbour of the black king on the board and only one white king will present on the board. The white pawns will never be on positions x1 (x = a, b, c, d, e, f, g, h). The possible values for each character are:
no figure on this square K black king
b white pawns
t white rooks
s white knights l white bishops d white queens k white kings
• PAWN: one of the chessmen of least value having the power to move only forward ordinarily one square at a time, to capture only diagonally forward, and be promoted to any piece except a king upon reaching the eighth rank
• ROOK: either of two pieces of the same color in a set of chessmen having the power to move along the ranks or files across any number of unoccupied squares. Also called castle
• KNIGHT: either of two pieces of the same color in a set of chessmen having an L-shaped move of two squares in one row and one square in a perpendicular row over squares that may be occupied
• BISHOP: either of two pieces of each color in a set of chessmen having the power to move diagonally across any number of adjoining unoccupied squares
• QUEEN: the most privileged piece of each color in a set of chessmen having the power to move in any direction across any number of unoccupied squares
• KING: the principal piece of each color in a set of chessmen having the power to move ordinarily one square in any direction and to capture opposing men but being obliged never to enter or remain in check
Suppose the chessboard starts at the lower left corner with the field a/1. Therefore white is playing upwards (Starting at a-h/1-8). EOF indicates the end of the input file.
2/2 Output
The output consists of : ‘checkmate’ or ‘draw’ or ‘game is not over’ without quotes. Sample Input
knnnnnnnpppppppppppppppprrrrrrrrrrrrrrrrnnnbqbqbnKnbqbqbnnnbqbqb
nrnrbqnnnpbnbbnqrkbrbprpnrpprqprqpnpnnbprbrqrqnnnnprpppKnqrrbqqq
nrrqbqbrnrpprpbpnbnprqnnnnbrppqqpqpnKqnpnpqrrprrnnbqqnrbqknbqqnn
Sample Output
draw
checkmate
game is not over