Conditional probability; two queens attack each other

chessboardconditional probabilityprobability

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.

Best Answer

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