<s>[INST] With how many ways can we choose $9$ balls of a box? With how many ways can we choose $9$ balls of a box that contains $12$ balls, of which $3$ are green, $3$ are white, $3$ are blue and $3$ are red?
$$$$
I have done the following:
$x_1=\# \text{ green balls that we choose }$
$x_2=\# \text{ white balls that we choose }$
$x_3=\# \text{ blue balls that we choose }$
$x_4=\# \text{ red balls that we choose }$
$$x_1+x_2+x_3+x_4=9, \ \ \ \ 0 \leq x_i \leq 3$$
$$\\$$
The number of solutions of the equation: $x_1+x_2+x_3+x_4=9, \  \  \ x_i \geq 0 \ \ \ $ is
$$\binom{9+4-1}{3}=\binom{12}{3}$$
Then I take the cases I don't want, to subtract them from the number above.
$x_1>3 \Rightarrow x_1 \geq 4$
$y_1=x_1-4 \geq 0$
So we become the equation:
$$y_1+4+y_2+y_3+y_4=9, \ \ \ y_i \geq 0 \ \ \ \ \Rightarrow y_1+y_2+y_3+y_4=5, \ \ \ y_i \geq 0$$
And the number of solutions are:
$$\binom{4+5-1}{3}=\binom{8}{3}$$
We do the same for $i=2,3,4$.
$$\\$$
Finally the solution is:
$$\binom{12}{3}- 4\cdot \binom{8}{3}=-4$$
That cannot be right..
What have I done wrong??
 [/INST] Assuming we do not care about the order in which the balls are selected, the number of ways of choosing $9$ balls from the box is the same as the number of ways of leaving $3$ balls in the box, which is much easier to calculate.
If we number the balls $1$ to $12$, then there are $12\choose 3$ ways of doing this.  But removing balls $1,4,7$ would be the same as removing $2,4,7$, since balls $1$ and $2$ are both red.  So we need to break it down to:


*

*Number of ways to leave one ball of each of $3$ colors = ${4 \choose 3} = 4$.

*Number of ways to leave two balls of one color and one ball of another color $ = 4\cdot 3 = 12$.

*Number of ways to leave three balls of one color = $4$.


Total number $= 4 + 12 + 4 = 20$ ways of removing $9$ balls.
</s>