<s>[INST] Use generating functions to determine the number of ways Use generating functions to determine the number of different ways $12$ identical action figures can be given to $5$ children so that each child receives at most $3$ action figures
So far I have come up with the generating function of: $$(1 + x + x^2 + x^3)^5$$
To correspond to each child having either $0, 1, 2, $ or $3$ action figures with each child representing a factor. But, I am confused as to how to expand this. Any help is appreciated, thanks!
 [/INST] It is convenient to use the coefficient of operator $[x^n]$ to denote the coefficient of $x^n$ of a series.  

We obtain
  \begin{align*}
[x^{12}]&(1+x+x^2+x^3)^5\\
&=[x^{12}]\left(\frac{1-x^4}{1-x}\right)^5\tag{1}\\
&=[x^{12}]\left(\sum_{k=0}^{5}\binom{5}{k}(-1)^kx^{4k}\right)\left(\sum_{n=0}^\infty\binom{-5}{n}(-x)^n\right)\tag{2}\\
&=\left(\binom{5}{0}[x^{12}]-\binom{5}{1}[x^8]+\binom{5}{2}[x^4]-\binom{5}{3}[x^0]\right)
\sum_{n=0}^\infty\binom{n+4}{4}x^n\tag{3}\\
&=\binom{5}{0}\binom{16}{4}-\binom{5}{1}\binom{12}{4}+\binom{5}{2}\binom{8}{4}-\binom{5}{3}\binom{4}{4}\tag{4}\\
&=1\cdot 1820-5\cdot 495+10\cdot 70-10\cdot 1\\
&=35
\end{align*}

Comment: 


*

*In (1) we use the formula for the finite geometric series

*In (2) we use the binomial series expansion for the denominator

*In (3) we use the linearity of the coefficient of operator and the rule $[x^{p-q}]A(x)=[x^{p}]x^{q}A(x)$. Note that we only need to respect $4$ of the $6$ summands of the series, since terms with exponents greater than $12$ do not contribute. We also use in the right series the binomial identity
\begin{align*}
\binom{-p}{q}=\binom{p+q-1}{p-1}(-1)^q
\end{align*}

*In (4) we select the coefficients from the right series accordingly to the coefficient of operator
</s>