Couldn't do without swearing...
You are given a 6×6 chessboard with three pieces: a white king, a white rook, and a black king. Your task is to determine the minimum number of moves required for white to checkmate the black king, or to establish if checkmate is impossible or if the position is invalid.
Input
The input consists of a single line containing three sets of coordinates, representing the positions of the white king, the white rook, and the black king, respectively. Following these coordinates, there is a space and then a character indicating which side moves first (W for white or B for black).
Output
Output the total number of moves required for white to achieve checkmate. If the black king is already in checkmate, output 0. If the position provided is invalid, output -1. If the game results in a draw (such as a stalemate), output -2.