Number of Valid Move Combinations On Chessboard
There is an 8 x 8 chessboard containing n pieces: rooks, queens, or bishops. You are given a string array pieces of length n, where pieces[i] describes the type of the i^th piece. You are also given a 2D integer array positions of length n, where positions[i] = [ri, ci] indicates that the i^th piece is currently at the 1-based coordinate (ri, ci) on the chessboard.
When making a move for a piece, you choose a destination square that the piece will travel toward and stop on.
- A rook can only travel horizontally or vertically from
(r, c)toward(r+1, c),(r-1, c),(r, c+1), or(r, c-1). - A queen can only travel horizontally, vertically, or diagonally from
(r, c)toward(r+1, c),(r-1, c),(r, c+1),(r, c-1),(r+1, c+1),(r+1, c-1),(r-1, c+1), or(r-1, c-1). - A bishop can only travel diagonally from
(r, c)toward(r+1, c+1),(r+1, c-1),(r-1, c+1), or(r-1, c-1).
You must make a move for every piece on the board simultaneously. A move combination consists of all the moves performed on all the given pieces. Every second, each piece instantaneously travels one square toward its destination if it is not already there. All pieces start traveling at the 0^th second. A move combination is invalid if, at a given time, two or more pieces occupy the same square.
Return the number of valid move combinations.
Notes:
- No two pieces will start in the same square.
- You may choose the square a piece is already on as its destination.
- If two pieces are directly adjacent to each other, it is valid for them to move past each other and swap positions in one second.
pieces = ["rook"], positions = [[1,1]]15pieces = ["queen"], positions = [[1,1]]22Constraints
- 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.