selection of balls of three colors with restrictions I have asked a similar question here and answers were very helpful. I tried doing similar questions and could solve them comfortably. However, I myself came up with a question like this and wondering how to solve this.
Suppose there are 20 black balls, 10  yellow balls and 5 brown balls. Balls of same color are identical. Order of selection does not matter.


*

*How many ways can a selection of 15 balls be made?

*How many ways can a selection of 15 balls be made if 2 brown must be selected always?


My approach
(1) number of solutions of $x_1+x_2+x_3 = 15$ with $0\le x_1\le 20; 0 \le x_2 \le 10; 0 \le x_3 \le5$ is the solution. Is this right? if so, is there any formula for this?
(2) Select the 2 brown balls in (only 1 way) and then find number of solutions of  $x_1+x_2+x_3 = 13$ with $0\le x_1\le 20; 0 \le x_2 \le 10; 0 \le x_3 \le3$
Please give directions on how to approach similar problems. thanks.
 A: Your approaches to both problems are correct. 
Since balls of the same color are indistinguishable, the number of ways $15$ balls can be selected from $20$ black balls, $10$ yellow balls, and $5$ brown balls is the number of nonnegative integer solutions of the equation 
$$x_1 + x_2 + x_3 = 15 \tag{1}$$
subject to the restrictions $x_2 \leq 10$ and $x_3 \leq 5$.  Note that since $20 > 15$, we do not need a restriction on the number of black balls. 
If there were no restrictions, the number of solutions of the equation 
$x_1 + x_2 + x_3 = 15$ would be equal to the number of ways of inserting two addition signs in a row of $15$ ones, which is $\binom{15 + 2}{2} = \binom{17}{2}$ since we must select which two of the seventeen symbols ($15$ ones and two addition signs) are to be addition signs.
From these, we must remove those solutions in which $x_2 > 10$ or $x_3 > 5$.  Note that it is not possible for both of these conditions to hold simultaneously since $11 + 6 = 17 > 15$.  
Suppose $x_2 > 10$.  Let $y_2 = x_2 - 11$.  Then $y_2$ is a nonnegative integer.  Moreover, substituting $y_2 + 11$ for $x_2$ in equation 1 yields
\begin{align*}
x_1 + y_2 + 11 + x_3 & = 15\\
x_1 + y_2 + x_3 & = 4
\end{align*}
Thus, the number of solutions of equation 1 in which $x_2 > 10$ is equal to the number of ways two addition signs can be placed in a row of four ones, which is $\binom{4 + 2}{2} = \binom{6}{2}$.  
Now, suppose $x_3 > 5$.  Let $z_3 = x_3 - 6$.  Then $z_3$ is a nonnegative integer.  Moreover, substituting $z_3 + 6$ for $x_3$ in equation 1 yields
\begin{align*}
x_1 + x_2 + z_3 + 6 & = 15\\
x_1 + x_2 + z_3 & = 9
\end{align*}
Thus, the number of solutions of equation 1 in which $x_3 > 5$ is the number of ways in which two addition signs can be placed in a row of nine ones, which is $\binom{9 + 2}{2} = \binom{11}{2}$.  
Hence, the number of ways $15$ balls can be selected from $20$ indistinguishable black balls, $10$ indistinguishable yellow balls, and $5$ indistinguishable brown balls is 
$$\binom{17}{2} - \binom{6}{2} - \binom{11}{2}$$
which agrees with the answer ml0105 obtained using generating functions.
You can apply the same method to solve the second problem you posed.
A: Are you familiar with generating functions? These will help a lot, as you can use them rather than writing out the inclusion-exclusion argument yourself.
A generating function uses the exponent of the variable to index the quantity. So $x^{0}$ indicates we have none of the given item, while $x^{5}$ indicates we have $5$ of the given item. The coefficient of the term indicates the number of ways to obtain that term, which is the count in which you are interested. 
Consider first the number of yellow balls. We have at most $10$ yellow balls, yielding the generating function for yellow balls:
$$f_{y}(x) = \sum_{i=0}^{10} x^{i} = \dfrac{1-x^{11}}{1-x}$$
Similarly, we have for brown balls: 
$$f_{br}(x) = \sum_{i=0}^{5} x^{i} = \dfrac{1-x^{6}}{1-x}$$
Now since we have more black balls than we can use, we can simply let the series go out to infinity:
$$f_{bl}(x) = \sum_{i=0}^{\infty} = \dfrac{1}{1-x}$$
Now we multiply the generating functions together to get:
$$f(x) = \dfrac{(1-x^{6})(1-x^{11})}{(1-x)^{3}}$$
Now we have that:
$$\dfrac{1}{(1-x)^{3}} = \sum_{i=0}^{\infty} \binom{3 + i - 1}{i} x^{i}$$
So:
$$f(x) = (1-x^{6})(1-x^{11}) \sum_{i=0}^{\infty} \binom{3+i-1}{i}x^{i}$$
We are interested in the coefficient of $x^{15}$. This yields:
$$\binom{3 + 15 - 1}{15} - \binom{3 + 9 - 1}{9} - \binom{3 + 4 - 1}{4}$$
The second term comes from multiplying with the $-x^{6}$ term, so we look $i = 9$ in the summation. Similarly, with $-x^{11}$, we look for the coefficient of $x^{4}$ in the summation.
The approach is similar for part (b).
