Chess attack

You are given pairs of chess pieces with locations; for each pair, you
are to output true if the first piece can attack the second, and false
otherwise.

Input

A number n ≥ 1, followed by n pairs of pieces.

Each piece is specified in the following format: type x y. Type is a
character: K for king, Q for queen, R for rook, B for bishop, and N for
knight. x and y are ints such that 0 ≤ x ≤ 7 and 0 ≤ y ≤ 7; they specify
the x and y coordinates of the piece’s position on the chessboard.

In each pair, the two pieces are guaranteed to be in different
positions.

Output

For each pair, output true if the first piece can attack the second, and
false otherwise. Refer to Wikipedia (or another internet source) for
information on how each of the pieces behave.

Observation

Problem information

Author: Hubie Chen

Generation: 2026-01-25T22:34:01.441Z

© Jutge.org, 2006–2026.
https://jutge.org
