Combinatorics – Number of Ways Two Knights Can Be Placed Without Attacking

combinatorics

What are the number of ways two knights can be placed on a k×k chessboard so that they do not attack each other?

For k from 1 to 8, the answer is given below. How do I find a general formula?
0
6
28
96
252
550
1056
1848

Edit:

Here's my approach after @Peter 's help, I came to a conclusion that number of ways such that they attack is equal to two times the number of possible ways I can put an "L" shape on the board. (2 times because knights can swap positions), am I right? I don't know how do I more forward from here.

I tried finding number of ways to place L by this recursive formula: F[n][n]=4+F[i][i-3]+F[i-2][3]; But it's not working.

Best Answer

Note that when we have two knights threatening each other, it actually forms either a $2\times3$ or $3 \times 2$ board. And for each of $2 \times 3$ and $3 \times 2$ boards, there are $2$ ways of placing two knights so that they threaten each other. So, what we should do is to count how many $2 \times 3$ and $3 \times 2$ squares on $n\times n$ board. For general $n$, the answer is $$(n-1)(n-2)+(n-2)(n-1) = 2(n-1)(n-2)$$ And for each $2\times3$ and $3\times2$ board, there are $2$ ways of placing the knights so that they threaten each other. Therefore, in total there are $$2\cdot2(n-1)(n-2)=4(n-1)(n-2)$$ ways of placing two knights so that they threaten each other. So what you are looking for is $$\frac{n^2(n^2-1)}{2}-4(n-1)(n-2)$$ It is also worth mentioning that we are not over-counting because whenever we place two knights so that they threaten each other, either a $2 \times 3$ or $3 \times 2$ board must contain both of the knights.