Skip to content

Practice Number of Valid Move Combinations On Chessboard

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#2056
LeetCode Problem

Number of Valid Move Combinations On Chessboard

Problem Statement

Each piece starts at its given one-based position on an 8 by 8 board. Choose a destination for every piece, possibly its starting square. Rooks move along a row or column, bishops along a diagonal, and queens along either. All pieces move simultaneously: each second, a moving piece advances one square toward its destination and stops there once reached. Count destination choices for which no two pieces occupy the same square at an integer time, including after a piece has stopped. Starting positions are distinct. Two neighboring pieces may swap squares in one second; crossing between squares does not invalidate that move.

Source: Number of Valid Move Combinations On Chessboard on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
pieces = ["rook"], positions = [[1,1]]
Output
15

# Example 2

Input
pieces = ["queen"], positions = [[1,1]]
Output
22

# Example 3

Input
pieces = ["bishop"], positions = [[4,3]]
Output
12

Constraints

n == pieces.length
n == positions.length
1 <= n <= 4
pieces only contains the strings "rook", "queen", and "bishop".
There will be at most one queen on the chessboard.
1 <= ri, ci <= 8
Each positions[i] is distinct.

Related LeetCode Problems

Practice more problems similar to Number of Valid Move Combinations On Chessboard.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.