Combinations of colored balls.

Suppose I have $3$ yellow balls, $2$ red balls and $4$ green balls. How many different combinations of colors can I get if I select $k$ balls?

For $k = 1$ it is easy. I can select a yellow, or a red or a green, i.e. $3$ in total.

For $k = 2$ I count $6$ possible combinations: YY, YR, YG, RR, RG, GG. But what is the general formula?

And what's the formula for the total sum of combinations, i.e. for the total number of ways I could present a selection of balls?


Solution 1:

The generating function is $(1+x+x^2)(1+x+x^2+x^3)(1+x+x^2+x^3+x^4)$ where the highest exponent is the number of balls of each color. You can expand it and find the coefficient of $x^k$.