i is of type kinds[i] ("rook", "queen" or "bishop") and stands on cells[i] = [r, c], with rows and columns numbered 1 to 8.
Each piece is given a destination it can reach by moving in a straight line: a rook horizontally or vertically, a bishop diagonally, a queen in any of those eight directions. The destination may also be the square the piece is already on.
All pieces start at the same moment and move one square towards their destination every second; once there, a piece stays put. A plan (a choice of destinations for all pieces) is invalid if at some moment two pieces are on the same square. Two neighbouring pieces swapping places within one second do not collide.
Return the number of valid plans.kinds=['bishop'], cells=[[1, 1]] → 8
A bishop in the corner can slide 1 to 7 squares along its diagonal or stay put: 8 options.
kinds=['rook'], cells=[[5, 4]] → 15
The rook can go to any of the 14 squares in its row and column or stay: 15 options.
kinds=['rook', 'rook'], cells=[[1, 1], [1, 2]] → 196
kinds) = len(cells) ≤ 4kinds[i] is "rook", "queen" or "bishop"cells are distinctkinds=['bishop'], cells=[[1, 1]]
8
Run checks the first 3 tests in your browser. Submit checks all 94 tests on the server, hidden ones included.