3

Maximum number of non-attacking pairs of queens in 8-Queens problem is given by 8 × 7/2 = 28. Can someone explain how it is 8x7/2?

manlio
  • 18,345
  • 14
  • 76
  • 126
user5492770
  • 357
  • 3
  • 5
  • 13
  • 1
    Every queen can have 7 non-attacking queens. 8 queens will have overall 8x7=56 non-attacking queens. Because pair contains of two queens - result 8x7 will be divided by 2. – Fabio Aug 11 '16 at 03:05
  • I'm voting to close this question as off-topic because it has nothing to do with programming at all. – Alejandro Oct 11 '17 at 18:46

2 Answers2

3

A non attacking pair is when two queens don't attack each other.For max condition no queen attacks any other queen, so number of non attacking pairs

1st queen would have = 7 2nd queen would have = 6 (exclude the pair with the 1st queen as its already counted in step 1)

Similarly, 3rd queen would have = 5

Thus, total number of non attacking pairs for 8 queens would be = 7+6+5+4+3+2+1+0 =28

1

Here is another thought process: We have 8 queens and you want to know every possible attacking pair on the board so we have 8 choose 2 or

8!/((8-2)!*2!) = 28
Kenan
  • 13,156
  • 8
  • 43
  • 50