What type of problem is this? Combinatorics? Given 10 cups and 8 non-distinct balls, how many ways can we distribute the balls among the cups such that no cup has more than 2 balls in it? Cups are allowed to be empty, as required by the problem statement. 
I've seen examples of placing items in containers, but rarely when the number of containers is greater than the number of items and never when a maximum number of items is specified per container. What type of formula or mathematics can I use? My first thought was to use the binomial coefficient of "n choose k", but that only works for n>k. Also, I don't know how to factor in the limit per container. Any insight would be appreciated. 
 A: I preassume that the cups are distinguishable.
Discern the cases:


*

*$8=4\times2+0\times1+6\times0$

*$8=3\times2+2\times1+5\times0$

*$8=2\times2+4\times1+4\times0$

*$8=1\times2+6\times1+3\times0$

*$8=0\times2+8\times1+2\times0$


Final answer is: $$\frac{10!}{4!0!6!}+\frac{10!}{3!2!5!}+\frac{10!}{2!4!4!}+\frac{10!}{1!6!3!}+\frac{10!}{0!8!2!}$$
A: There are much smarter ways to do it, but full enumeration works too. There are $\binom{10}{4}$ ways to select the cups if 2 balls go ibto each and $\binom{10}{8}$ if exactly 1 goes into each. These are boundary cases. To get from the former to the latter, just start by rsmoving 1 ball from any cup. What do you get?
A: You can also solve this using generating functions. Each cup can have 0, 1, or 2 balls and the total number of balls should be 8.
For each cup we associate the polynomial $(1+x+x^2)$ and multiply ten such terms together (one for each cup). So the expression we have is $(1+x+x^2)^{10}$. If you expand this out without simplifying, a term $x^k$ comes from a choice of 1, $x$, or $x^2$ from the first cup, a choice from the second cup, etc. And so $x^k$ represents one way of putting $k$ balls into 10 cups. (Try doing this with smaller numbers).
Simplifying the expression (i.e., write it as $a_0 + a_1x+ \dots + a_{20}x^{20}$), we see that the coefficient of $x^k$ is the number of ways of putting $k$ balls into 10 cups. So the coefficient of $x^8$ tells you how many ways you can put 8 balls into 10 cups. (You can come up with relatively short formula for computing this coefficient).
While this is not the shortest or simplest way of solving this problem, it is a very useful technique.
