Hide

Problem K
Discoveries

Languages en sv

Jonathan is writing a chess engine and he’s running into issues with discovered checks. Can you help him figure out if a given move made by the white pieces will lead to a discovered check against the opponent? A discovered check is a move that places the opponent in check by unveiling another piece.

/problems/discoveries/file/statement/en/img-0001.png
Chessboard with squares marked cc by-sa

Input

First $8$ lines of input contain $8$ characters each. Each character describes the piece placed on that square. If it is a uppercase letter, then the piece belongs to white, otherwise the piece belongs to black.

Each piece is represented by a character, see the table below for the desciption of which charater corresponds to which piece.

Then follows one line containing four characters. The first two of these signify the location of the piece being moved, and the second two signify the destination of that piece. Each of these two pairs start with the column (a through h, left to the right) which is followed by the row (1 through 8, bottom to top). For example a1 would be the bottom left corner and a8 would be the top left corner. It is guaranteed that the move is a legal chess move (that isn’t a capture or en passant1) and that it is white’s turn to move. The chessboard is in a state that is possible in a standard game of chess.

Piece

Representation

None

_

Pawn

p

Knight

n

Bishop

b

Rook

r

Queen

q

King

k

Output

Print a 1 if the move is a discovered check, otherwise 0.

Points

Your solution will be tested on a number of test-case groups. To receive points for a group, your solution must correctly solve every test-case in the group.

Group

Point Value

Constraints

$1$

$40$

White has no bishops or queens.

$2$

$40$

White has no rooks or queens.

$3$

$20$

No further constraints.

Sample Input 1 Sample Output 1
rnbqkbnr
pppppppp
________
________
________
________
PPPPPPPP
RNBQKBNR
e2e4
0
Sample Input 2 Sample Output 2
_______K
________
________
k____N_R
________
________
________
________
f5g3
1

Footnotes

  1. The specifics of this special rule are not relevant to the problem as en passant moves do not appear in the input.

Please log in to submit a solution to this problem

Log in