An easy chess problem

You are given a chessboard, a white piece and a black piece. Each piece
can be a king, a queen, a rook, a bishop, or a knight. In how many ways
can you place the two pieces so that no piece threatens the other piece?
For instance, these are three of the 3612 ways to place two kings on the
board:

Input

Input consists of several cases, each one with two chars to indicate the
pieces: ‘K’ for a king, ‘Q’ for a queen, ‘R’ for a rook, ‘B’ for a
bishop, and ‘N’ for a knight.

Output

For every case, print the number of ways the place the given pieces on
the board.

Problem information

Author: Enrique Jiménez

Generation: 2026-01-25T10:01:32.861Z

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