<s>[INST] Purchasing Donuts 
At closing time at a Dunkin Donuts store they still have $10$ vanilla,
  $20$ custard, $24$ cinnamon, and $30$ chocolate donuts available.
  Donuts of the same kind are regarded as identical.   
(a) How many ways are there to purchase $8$ donuts?
(b) How many ways are there to purchase $15$ donuts with at least
  three of each kind? 
(c) How many ways are there to purchase $15$ donuts?

Part (a):
We have four different flavor donuts to choose from. We would like to purchase $8$ of them. So this is a stars and bars problem. We have $8$ stars and $3$ bars. So this is $\binom{8+3}{3}=\binom{11}{3}=165$ ways. 
Part (b):
Step $1$: Put three of each kind in the box. 
Now we need to purchase $3$ more donuts. This is again, stars and bars. 
$\binom{3+3}{3}=\binom{6}{3}=20$ ways. 
Part (c):
I know we need to be careful because there are only $10$ vanilla donuts left. 
This will be a stars and bars problem. 
How do I go about this problem?
 [/INST] 
(c) How many ways are there to purchase $15$ donuts?

The question can be formulated as:
$$x_1+x_2+x_3+x_4=15,\\
0\le x_1\le 10,\\
0\le x_2\le 20,\\
0\le x_3\le 24,\\
0\le x_4\le 30,$$
which is equivalent to:
$$x_1+x_2+x_3+x_4=15,\\
0\le x_1\le 10,\\
0\le x_2\le 15,\\
0\le x_3\le 15,\\
0\le x_4\le 15.$$
which is the difference between (1):
$$x_1+x_2+x_3+x_4=15,\\
0\le x_1\le 15,\\
0\le x_2\le 15,\\
0\le x_3\le 15,\\
0\le x_4\le 15,$$
and (2):
$$x_1+x_2+x_3+x_4=15,\\
11\le x_1\le 15,\\
0\le x_2\le 15,\\
0\le x_3\le 15,\\
0\le x_4\le 15,$$
(1):${15+4-1\choose 4-1}={18\choose 3}$.
(2):
$$x_1+x_2+x_3+x_4=15,\\
11\le x_1\le 15,\\
0\le x_2\le 15,\\
0\le x_3\le 15,\\
0\le x_4\le 15,$$
which is equivalent to (let $x_1=y_1+11$):
$$y_1+x_2+x_3+x_4=4,\\
0\le y_1\le 4,\\
0\le x_2\le 4,\\
0\le x_3\le 4,\\
0\le x_4\le 4,$$
which is: ${4+4-1\choose 4-1}={7\choose 3}$.
Thus, the final answer is: ${18\choose 3}-{7\choose 3}=781$.
</s>