Number of bijective functions on a finite set I was trying the following problem:

Find the number of bijective functions $f:\{1,2,3,4\}\rightarrow \{1,2,3,4\}$ such that $f(1)\neq 3, f(2)\neq 1, f(3)\neq 4, f(4)\neq 2.$

My attempt is the following one:
Consider the subsets of bijections
$A_1=\{f: f(1)=3\}$,$\;\;A_2=\{f: f(2)=1\}$, $A_3=\{f: f(3)=4\}$,$\;\;A_4=\{f: f(4)=2\}$.
So
$\begin{align}\vert\cup_i A_i\vert&=\,^4C_1\!\cdot\!3!-\,^4C_2\!\cdot\!2!+\,^4C_3\!\cdot\!1!-\,^4C_4\!\cdot\!0!=\\&=24-12+4-1=15.\end{align}$
Hence the required answer is $\,24-15=9$.
Is my solution correct? If not please help.
 A: I summarize the comment by JMoravitz to provide an answer, so the question can be closed.
The solution is correct. Equivalently, we may ask for the number of bijections such that $f(i)\neq i$ for all $i\in\{1,\dots,4\}$, since the number of such bijections is invariant to the choice of the forbidden elements per position. Hence, we ask for the number of derangements, and next to the inclusion-exclusion formula we obtain the equivalent result $\lfloor\frac{4!}{e}+\frac{1}{2}\rfloor$, for example.
A: Let us say we do not have any restriction and we want to find the number of bijective functions from $\{ 1,2,3,4 \}\to \{1,2,3,4 \}$
Every element has a unique image. Let first element we map has 4 choices then second , third and fourth element will have 3 , 2 and 1 choice.
Thus the total number of bijective maps will be $4!$ (if no restriction)
The condition states that f(1)≠3 or f(2)≠1 or f(3)≠4 or f(4)≠2. This means that there are 3! = 6 bijections that map 1 to a value other than 3, 3! = 6 bijections that map 2 to a value other than 1, 3! = 6 bijections that map 3 to a value other than 4, and 3! = 6 bijections that map 4 to a value other than 2. But since we are counting each bijection multiple times, we are overcounting the bijections which are counted multiple times. So we should correct the count by dividing with the number of sets in which a bijection is counted. There are 4 sets in which a bijection is counted, so 4! = 24, so the correct count is (6+6+6+6)/4 = 6.
Therefore, the number of bijective functions f:{1,2,3,4}→{1,2,3,4} such that f(1)≠3 or f(2)≠1 or f(3)≠4 or f(4)≠2  is 24 - 6 = 18.
