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?
|
Yes, you can do it with generating functions: |
|||||||||
|
|
Your problem is equivalent with this one. $x_1+x_2+x_3+x_4=3$ where $0\le x_1\le 1,~0\le x_2\le 1, 0\le x_3\le 2,~0\le x_4\le 3$ $0+0+0+3=3$ $0+0+1+2=3$ $0+1+0+2=3$ $1+0+0+2=3$ $0+0+2+1=3$ $0+1+2+0=3$ $1+0+2+0=3$ $0+1+1+1=3$ $1+0+1+1=3$ $1+1+0+1=3$ $1+1+1+0=3$ |
|||
|
|