This question has been asked before, but I wanted to approach it via derangements: and I haven't seen this answered satisfactorily on MSE using derangements.
Let $A=(1,2,3,4,5)$ and $B=(0,1,2,3,4,5)$. We need to find construct one-one functions $f$ from $A$ to $B$, such that $f(1)\neq0$ and $f(i)\neq i$ for $i$ in $\{1,2,3,4,5\}$.
Approach: Since $B$ has $6$ elements and $f$ is one-one, there will be one element $e$ in $B$ that has no pre-image.
- If $e$ is $0$, then we simply have $d(5)=44$ cases.
- If $e$ is $1$, we again have $d(5)=44$ cases, since $1$ cant be associated with $0$.
- Suppose $e$ belongs to $(2,3,4,5)$. There are $4$ ways to do this.For instance , let $e$=$3$. Then, suppose $f(3)=0$: we have a total of $d(4)$ cases. If $f(3)=1$, we again have $d(4)$ cases. Now suppose $f(3)$ belongs to $(2,4,5)$:There are three cases.
Say $f(3)=2$. Now We need to map $(1,2,4,5)$ to $(0,1,4,5)$ (under the original constraint, ofcourse). There should be $d(3)-d(2)$ ways to do this: since $2$ cant map to $2$, we only need to worry about $(1,4,5)$ :i.e $d(3)$ cases. However these $d(3)$ cases consider the cases where $4$ and $5$ are deranged but $1$ is associated to $0$ ,($d(2)$ cases), which we need to subtract. So, all in all, we need to consider $d(3)-d(2)$ cases.
Which makes the final answer: $d(5)+d(5)+ 4[d(4)+d(4)+3(d(3)-d(2))]=232$.However the correct answer is $256$.
I think the cases where $e=1$ and $e=0$ are correct.Any insight/corrections regarding my approach in the treatment of cases involving $e$ belonging to $(2,3,4,5)$ will be appreciated.
In the 3rd case, I'd just make 2 cases. We are counting the number of permutations $\pi:\{1,2,4,5\}\mapsto\{0,1,4,5\}$ such that $\pi(1)\notin \{0,1\}, \pi(4)\neq4$ & $\pi(5)\neq 5$.
$2$ gets mapped to $0$ or $1$. For each of these, we have $d(3)$ possible assignments of $(1,4,5)$
$2$ gets mapped to $4$ or $5$. For each of these, $1$ must get mapped to $5$ and $4$ respectively. So we have 2 possible assignments for $4$ and $5$ for each such assignment of $2$.
The final answer then comes to $2d(5)+4(2d(4)+3(2d(3)+2+2)) = 256$