Why is the maximum number of non-attacking pairs of queens in the 8-queen problem?

1.5k Views Asked by At

In the 8-queen’s problem we want the number of attacking pairs of queens to be zero in the solution assignment of the queens.

A possible fitness function is the number of non-attacking pairs of queens that we are interested to maximize which has the maximum value $\dbinom{8}{2}$ = 28.

I'm very sorry but I can't figure out why so ... Could you help me understand it as if I was a 10 years old? I'm quity rusty on my maths (but I'm very motivated :))

1

There are 1 best solutions below

0
On BEST ANSWER

If we have $8$ queens, there are $\binom 82 = 28$ ways to choose two of them: that's the number of pairs of queens we have, total.

What is $\binom 82$, exactly? It is $\frac{8 \cdot 7}{2}$. We have $8$ ways to choose the first queen in the pair, and $7$ ways to choose the second queen, different from the first. But then we divide by $2$, because each pair of queens $\{X,Y\}$ was counted twice: taking $X$ as the first queen and $Y$ as the second, and taking $Y$ as the first queen and $X$ as the second.

Each pair of queens can either attack each other, or not. For our fitness function, we go through all $28$ pairs of queens, and add $1$ to the score if they do not attack each other.

Since there are only $28$ pairs, the maximum score we can get in this way is $28$.