# Conditional probability; two queens attack each other

Two queens are randomly placed on a chessboard. What is the probability that they attack each other?

A: two queens randomly placed on a chessboard (condition)

B: they attack each other

I have 2016 ways to place two queens on a chessboard or $$\binom{64}{2}$$. If I fix one queen on a chessboard I am left with 63 places to put second queen. After placing first one, no matter where I place it, I have 21 places to put second queen so that it attacks the first queen(7 for diagonal, vertical and horizontal places). Intuitively, the solution would be $$\frac{\binom{21}{1}}{\binom{63}{1}}$$ or $$\frac{21}{63}\approx0.33$$. In my textbook the solution is $$\frac{241}{672}\approx0.35$$. Since this is a question from conditional probability I know I have to use this formula P(B\A)=$$\frac{P(AB)}{P(A)}$$.I know P(A)=2016, but I get confused when finding intersection AB because it is very similar to B\A, for me.

• It is not correct for the diagonal places, they are more than 7. For example, you have 7 diagonal places for the four corners, but places in the middle of the chessboard "see" two diagonals. Commented Apr 6, 2020 at 12:49
• Note that one generally shouldn't accept (the check mark) an answer until waiting 24 hours. This gives other people around the world a chance to give their answers, and only then, if there is one outstanding answer, should it be accepted as complete and best. Commented Apr 6, 2020 at 13:47
• @RayButterworth sorry I am new here, I'll keep that in mind. Commented Apr 6, 2020 at 13:52

We can break up this problem into three disjoint possibilities.

1. They share a row
2. They share a column
3. They share a diagonal

So, the number of ways for them to share a row: Choose one of the eight rows. Choose two of the eight squares of the row.

Total probability that they share a row: $$\dfrac{\dbinom{8}{1}\dbinom{8}{2}}{\dbinom{64}{2}}$$

Similarly, they share a column with the exact same probability.

Finally, let's figure out the probability they share the same diagonal.

There are $$4$$ diagonals each with exactly $$2,3,4,5,6$$ or $$7$$ squares squares. There are two diagonals with exactly eight squares.

So, the total number of ways to arrange two queens on the same diagonal:

Choose the size of the diagonal, choose the diagonal, choose two squares of the diagonal.

$$\dbinom{2}{1}\dbinom{8}{2}+\sum_{k=2}^7 \dbinom{4}{1}\dbinom{k}{2} = 280$$

So, the total probability that two queens attack each other if they are placed on random squares:

$$\dfrac{8\dbinom{8}{2}}{\dbinom{64}{2}} + \dfrac{8\dbinom{8}{2}}{\dbinom{64}{2}} + \dfrac{280}{\dbinom{64}{2}} = \dfrac{728}{2016} = \dfrac{13}{36}$$

Edit: This answer is different from the textbook's answer. I am not sure what I could have done wrong. It is not possible for two queens to share the same row and the same column as this would imply they share one square. If they share the same diagonal, both their row and column are different, and it is not possible to share two distinct diagonals at the same time. So, each case seems to be disjoint, and thus additive.

Edit 2: I actually verified my answer using a script to brute-force calculate the probability. This script returns "Num Attacking: $$728$$ Out of: $$2016$$". Here is the script I used:

Sub Test()
numAttacking = 0
numConfigurations = 0
For a = 0 To 62
rNumA = a Mod 8
cNumA = Int(a / 8)
For b = a + 1 To 63
numConfigurations = numConfigurations + 1
rNumB = b Mod 8
cNumB = Int(b / 8)
If rNumA = rNumB Or cNumA = cNumB Or rNumA + cNumA = rNumB + cNumB Or rNumA - cNumA = rNumB - cNumB Then
numAttacking = numAttacking + 1
End If
Next b
Next a
MsgBox "Num attacking: " & numAttacking & vbCrLf & "Out of: " & numConfigurations
End Sub

• I think your answer is correct. Commented Apr 6, 2020 at 14:09
• Hi. One silly doubt: when do we take $64\times63$ and when $^{64}C_2$? Because my first thought process was: number of ways to place first queen$=64$ and ways to place second queen$=63$. Commented Feb 4, 2022 at 5:49
• @aarbee $64\times 63$ implies you care which order you placed the queens. Suppose you place a queen in the top right and bottom right squares. How is that different from placing them in the bottom right and top right squares? Because you are checking to see if the queens are attacking each other, they are indistinguishable. Hence, you should use combinations rather than permutations. Commented Feb 4, 2022 at 6:02
• @aarbee that said, you are likely to get the same result using permutations as you are with combinations. If you assume you place one queen, then a second queen, and you track which queen went where, you will get the same probability in the end. It basically multiplies the numerator and denominator by 2. Commented Feb 4, 2022 at 6:40
• Thanks, means a lot. Commented Feb 4, 2022 at 9:18