I came across following problem:
How many number of 5 letter words that use letters from the 3 letter set {a,b,c} in which each letter occur atleast once?
This can be solved manually by enumerating individual cases as follows:
Number of words contains no A: 32, no B:32, no C:32. Total:96. Each of AAAAA,BBBBB and CCCCC are counted twice. Thus 96-3 = 93. Number of letters in which each letter occurs at least once = $3^5-93=150$
Now I see that this problem sounds like a problem of number of onto function from set A (with n elements) to set B (with k elements) which solution is given as $k! \begin{Bmatrix}n\\k\\\end{Bmatrix}$ where $\begin{Bmatrix}n\\k\\\end{Bmatrix}$ is a Stirlings number of second kind.
In onto function elements of set $A$ are distinguishable. Elements of set $B$ are distinguishable groups. And each group should have at least 1 element. This exactly maps to the above problem, where $A=\{a,b,c\}$ and $B=\{$5 letter word$\}$.
So, if I am not wrong, in above question $n=3$ and $k=5$. But we cannot define $\begin{Bmatrix}3\\5\\\end{Bmatrix}$. So how we can use Stirling number's onto functions counting approach to this problem. Surprisingly, if we make it reverse, i.e. $n=5$ and $k=3$, then answer comes correctly as $3! \begin{Bmatrix}5\\3\\\end{Bmatrix}=150$. How it works if I reverse the values of $n$ and $k$. Am I wrong in thinking that its $n=3$ and $k=5$ in this question? Or I miss something?