Let $n$ be a positive integer and Denote by $X$ the set of all functions $f$ from the set $A=\{1,2,...n\}$ to the set $B=\{1,2,3 \} $.
Calculate the number of functions $f:A \rightarrow B$ satisfying the condition $f(1) \le f(2)...\le f(n)$
This is an exam practice question for Discrete Math and I am trying to understand the solutions given. It is a relatively straight forward question, but the solutions aren't very clear.
It says that the list of values $(f(1),f(2),...,f(n))$ must have the form $(1,1,..,1,2,2,,,2,3,3,,,3)$. Let $k_i$ be the number of entries equal to $i$ in such a list for $i = 1,2,3$. The number of lists of this form is $k_1 + k_2 + k_3 = n$.
This is all fine, and then it says:
The number of such triples is ${n+2}\choose{2}$.
There is no further explanation. My first thought was that the solution would be the stirling number $S(n,3)$, but this clearly also counts functions which do not satisfy the condition. How was the solution of the number of triples derived?
Many thanks!