# The number of ways to arrange 8 rooks on the chessboard satisfying the condition

I have an interesting combinatorial math problem as follows

How many ways are there to arrange 8 rooks on the chessboard such that no rook is on the main diagonal (the diagonal connecting the top left and bottom right corners) and no rooks eats another?

I numbered the 8 vertical columns of the chessboard. Obviously there are no 2 rooks in the same row, so for each arrangement of 8 rooks i represent as an 8 digit number $$a_{1}a_{2}... a_{8}$$ where $$a_{i}$$ is the position of rook i. Since no rook can be matched, the number above must be a different 8-digit number made up of the digits 1,2,...,8. moreover, obviously $$a_{i}=i$$ doesn't exist (I'm stuck here) Everyone please comment and thank you so much for it

• Is the problem still unsolved? Commented Aug 17, 2023 at 14:42
• by eats do you mean no rooks are in danger of being attacked by another? Commented Aug 17, 2023 at 14:50
• @wjmccann that right Commented Aug 19, 2023 at 4:23

As you have discovered, the number of such arrangements is the same as the number of permutations of the set $$\{1,2,\ldots,8\}$$ with no fixed points. These are known as derangements. Using the formula from the article, we get an answer of $$d_8 = 8! \sum_{i=0}^8 \frac{(-1)^i}{i!} = 14833.$$

• oh thank you so much One of my Vietnamese friends also had the same result, but when my teacher wrote the code, the computer output was 9712 (maybe there is an error) Commented Aug 19, 2023 at 4:25

Using a vizualization of the board with rooks placed as a 8x8 binary matrix (0=no rook, 1=rook) this seems to be the number of traceless binary matrices where each row and each column sums to 1, as counted in https://oeis.org/A000166 . This gives 14833 for the 8x8 board.

• Thank you for this new knowledge I will look into it more Commented Aug 19, 2023 at 4:26