Determine number of function given two sets and properties Let A={1,2,3,4,5,6,7} and B={v,w,x,y,z}. Determine the number of functions $f:A \rightarrow B$ where (i) f(A)={v, x}; (ii) |f(A)|=2
For (i) the answer key gives 2!S(7, 2) and (ii) $\binom{5}{2}[2!S(7,2)]$
I don't understand where these answers come from. So the sterling number of the second kind shows how many non empty subsets of size 2 can be made from the domain A but why is 2! used and where does the $\binom{5}{2}$ in (ii) come from?
 A: To answer your first question, the factor of $2!$ arises from the following.  If you look at the subset of $A$ that maps to $v$, and similarly for $x$, you obtain a partition of $A$ into two parts, but those parts are unordered.  Exchanging the roles of $v$ and $x$ gives a distinct function.  How many ways are there to rearrange the two element set ${v, x}$?
$$2!$$
As for your second question, out of the five element set $B$, you must choose $2$ elements to be the range, and then the previous calculation applies.  How many choices are there?
$$
\binom{5}{2}
$$
A: Well, $S(7,2)$ is the number of ways to partition $A$ into two non-empty sets. We need to know this, since, in order to have $f(A)=\{v,x\},$ we need $f$ to be a function such that $A$ is the disjoint union of the sets $$\{n\in A:f(n)=v\}$$ and $$\{n\in A:f(n)=x\}.$$ These two sets cannot have any elements in common, since we want $f$ to be a function. Both of these sets must be non-empty, since we want $\{v,x\}\subseteq f(A).$ Every element of $A$ must lie in one of the two sets, since we want $f(A)\subseteq\{v,x\}.$ Once we've partitioned $A$ into two non-empty subsets, though, we must still pick which set's elements get sent to $v$ and which set's elements get sent to $x.$ There are $2!$ ways to do this. Hence, there are $2!S(7,2)$ functions of the first type.
For the second one, the idea is much the same, but the range of $f$ can be any $2$-element subset of $B$. How many such subsets are there?
