How many ways can $2$ rooks and a bishop be placed on a $4\times 4$ board such that no piece attacks another piece?
I stumbled upon this question and I don't know how to find the answer mathematically. I wrote this piece of code to find the answer to it. I think the code is right, but I get the answer as $232$, which doesn't "feel" right. So how do you actually go about solving this question?
Brute force.
Observation : The bishop can be treated as a queen! We place Q first, then two identical rooks R1, R2.
There are three kinds of squares : corner (4), edge (8), center (4). We place first Q on each type and then two rooks.
Center : Q clears a $3\times 3$ grid and one more corner and two edge squares. Only four squares remain. Total $:4\cdot 2\cdot 2=16$ ways.
Corner : Q clears two edges and one diagonal. Six squares remain. Choosing any one of these six for R1 leaves three squares out for R2. Total $:(4\cdot 6\cdot 3)/2=36$
Edge : Q clears an edge and a row/column and three more on its two diagonals. Six squares remain. If R1 is anywhere on one of three squares of an outer edge, it gives $2$ choices each for R2. Other three squares are at a knight's distance from Q. R1 on lonely square leaves 4 choices for R2. R1 on other pair of squres leaves $3$ choices each for R2. Total $$8\times \frac{3\cdot 2+4+2\cdot 3}{2}=64$$
Grand total $: 16+36+64=116$