Solution:
Let r, b, w, and y denote the number of red, blue, white, and yellow chips selected, respectively. We want the number of integer solutions to
r+b+w+y=9
subject to 0≤r≤3, 0≤b≤3, 0≤w≤3, 0≤y≤3.
Since there are only 3 of each color, the maximum for each variable is 3.
We can use generating functions. The generating function for each color is (1+x+x2+x3). The generating function for the total is
(1+x+x2+x3)4
We want the coefficient of x9 in this expansion.
Let us expand (1+x+x2+x3)4.
Alternatively, note that r+b+w+y=9 and 0≤r,b,w,y≤3.
Let us count the number of non-negative integer solutions to r+b+w+y=9 with r,b,w,y≤3.
We can use the inclusion-exclusion principle.
Let N be the number of non-negative integer solutions to r+b+w+y=9 with r,b,w,y≤3.
Let S be the set of all non-negative integer solutions to r+b+w+y=9.
The number of non-negative integer solutions is (4−19+4−1)=(312)=220.
Now, subtract the solutions where at least one variable exceeds 3.
Let A be the set where r≥4, B where b≥4, C where w≥4, D where y≥4.
By inclusion-exclusion:
N=S−(∣A∣+∣B∣+∣C∣+∣D∣)+(∣A∩B∣+∣A∩C∣+∣A∩D∣+∣B∩C∣+∣B∩D∣+∣C∩D∣)−(∣A∩B∩C∣+∣A∩B∩D∣+∣A∩C∩D∣+∣B∩C∩D∣)+∣A∩B∩C∩D∣
First, ∣A∣ is the number of solutions with r≥4. Let r′=r−4≥0, so r′+b+w+y=5. The number of non-negative integer solutions is (4−15+4−1)=(38)=56.
Similarly, ∣B∣=∣C∣=∣D∣=56.
Now, ∣A∩B∣ is the number of solutions with r≥4 and b≥4. Let r′=r−4≥0, b′=b−4≥0, so r′+b′+w+y=1. The number of non-negative integer solutions is (4−11+4−1)=(34)=4.
There are (24)=6 such pairs, so the sum over all pairs is 6×4=24.
Now, ∣A∩B∩C∣ is the number of solutions with r,b,w≥4. Let r′=r−4, b′=b−4, w′=w−4, so r′+b′+w′+y=9−4×3=−3. There are no non-negative integer solutions to this equation, so ∣A∩B∩C∣=0.
Similarly, all triple and quadruple intersections are zero.
So,
N=220−4×56+6×4=220−224+24=20
Therefore, there are 20 ways to select nine chips from the bag.