Combinatorics – Number of Combinations Without Repetition with Limited Supply

combinatorics

Say, I got $1$ red ball, $1$ blue, $2$ yellow, $3$ green, totally $7$ balls.
I wanna select $3$ balls from them. How many ways I can do this?I counted manually
$$123, 124, 133, 134, 144, 233, 234, 244, 334, 344, 444,$$ so $11$ combinations.Is there a formula for it?

Best Answer

Yes, you can do it with generating functions:
For the blue or red balls: $1+x$ (either you take none or one).
For the yellow ball: $1+x+x^2$ (either you take none or one or two).
For the green ball: $1+x+x^2+x^3$ (either you take none or one or two or three).
Hence the generating function for this problem would be: $$(1+x)^2(1+x+x^2)(1+x+x^2+x^3)=1+4x+8x^2+11x^3+11x^4+8x^5+4x^6+x^7$$ The coefficient of $x^n$ is exactly the number of options to choose exactly $n$ balls. Here, the coefficient of $x^3$ is $11$, which is the number of options to choose $3$ balls.

Related Question