[Math] How many ways can you put: a) two bishops b) two knights c) two queens on a chessboard in such a way that one piece does not attack the other

combinatorics

How many ways can you put:
a) two bishops
b) two knights
c) two queens
on a chessboard in such a way that one piece does not attack the other?

Best Answer

Let $R$ ($H,\ B,\ Q$) be the number of ways you can put two rooks (knights, bishops, queens) on the $8\times8$ chessboard so that they do attack each other.

$R=\frac{64\cdot14}2=448.$

$H=2\cdot2\cdot7\cdot6=168,$ since a pair of mutually attacking knights determines a $2\times3$ or $3\times2$ rectangle, there are $7\cdot6+6\cdot7=2\cdot7\cdot6$ such rectangles on the board, and there are two ways to place the knights in each rectangle.

$B=2\left(\binom22+\binom32+\binom42+\binom52+\binom62+\binom72+\binom82+\binom72+\binom62+\binom52+\binom42+\binom32+\binom22\right)$
$=4\left(\binom22+\binom32+\binom42+\binom52+\binom62+\binom72\right)+2\binom82=4\binom83+2\binom82=280.$

$Q=R+B=448+280=728$

So the answers are:

a) Nonattacking bishops: $\binom{64}2-B=2016-280=\boxed{1736}$

b) Nonattacking knights: $\binom{64}2-H=2016-168=\boxed{1848}$

c) Nonattacking queens: $\binom{64}2-Q=2016-728=\boxed{1288}$


Generalizing to the $n\times n$ chessboard, I get:

$R_n=2n\binom n2=n^2(n-1)$

$H_n=4(n-1)(n-2)$

$B_n=4\binom n3+2\binom n2=\frac{n(n-1)(2n-1)}3$

$Q_n=R_n+B_n=4\binom n3+(2n+2)\binom n2=\frac{n(n-1)(5n-1)}3$


More generally, for the $m\times n$ chessboard:

$R_{m,n}=m\binom n2+n\binom m2$

$H_{m,n}=2(m-1)(n-2)+2(n-1)(m-2)$

$B_{m,n}=4\binom{\min(m,n)}3+2(|m-n|+1)\binom{\min(m,n)}2$

$Q_{m,n}=R_{m,n}+B_{m,n}$


P.S. In a comment Djura Marinkov pointed out the alternative expression $$B_n=2\sum_{k=1}^{n-1}k^2$$ which comes from considering that, just as each pair of mutually attacking knights lie at opposite corners of a $2\times3$ or $3\times2$ rectangle, each pair of mutually attacking bishops lie at opposite corners of an $h\times h$ square, $2\le h\le n.$ Equating the two expressions for $B_n,$ we get yet another combinatorial proof of the familiar identity $$\sum_{k=1}^nk^2=2\binom{n+1}3+\binom{n+1}2=\binom{n+1}3+\binom{n+2}3=\frac{n(n+1)(2n+1)}6.$$