There are 7 dwarfs working in a mine: D1, D2,..., D7. There are 7 tasks to do in a mine: T1, T2,..., T7. Each dwarf can do only one task. Dwarf D1 won't do task T1, dwarf D4 won't do task T2, dwarf D5 won't do task T6, dwarf D6 won't do tasks T3 and T7. Count the number of ways to distribute Tasks to Dwarfs.
Well this is how I tried counting. For T1 I can pick one of 6 dwarfs (D1 can't do it). For T2 I can pick one of 6 dwarfs (if D4 was picked to do T1 previously) or one of 5 dwarfs (if some other dwarf was picked for T1 + D4 can't do it). and so on... so the result would start like: 6 * 6 + 6 * 5 for only 2 tasks... there are a lot of combinations for all of them together.
The problem can be solved using rook polynomials using a board with three $1\times 1$ and one $1\times 2$ disjunct forbidden subboards.
The three $1\times 1$ subboards each have rook polynomial $1+x$ and the $1\times 2$ subboard had rook polynomial $1+2x$ and, since they are all disjunct we can multiply to get the rook polynomial $R(x)$ for the entire forbidden subboard:
$$R(x)=(1+x)^3(1+2x)=1+5x+9x^2+7x^3+2x^4$$
then the desired count is given by the substitution $x^k=(-1)^k(7-k)!$ in $R(x)$ above:
$$7!-5\cdot 6!+9\cdot 5! -7\cdot 4!+2\cdot 3!=2364\tag{Answer}$$
This can be checked using the rook polynomial solver with the following board for which Dwarfs are numbered and jobs are A to G.
Forbidden task assignments (black squares) comprise the forbidden subboard for which we have the rook polynomial $R(x)$ above.
I highly recommend rook polynomials for this kind of question, there is plenty of material available online to explain them in more detail.