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??

Generating function solution: Each color is represented by:
$$
1 + z + z^2 + z^3 = \frac{1 - z^4}{1 - z}
$$
All four colors are then:
$$
\left( \frac{1 - z^4}{1 - z} \right)^4
$$
and you want 9 balls, i.e., the coefficient of $z^9$, ellipses are terms that don't affect the result:
\begin{align}
[z^9] \left( \frac{1 - z^4}{1 - z} \right)^4
  &= [z^9] \frac{(1 - z^4)^4}{(1 - z)^4} \\
  &= [z^9] (1 - 4 z^4 + 6 z^8 - \ldots) (1 - z)^{-4} \\
  &= [z^9] (1 - z)^{-4} - 4 [z^5] (1 - z)^{-4} + 6 [z] (1 - z)^{-4} \\
  &= (-1)^9 \binom{-4}{9}
       - 4 \cdot (-1)^5 \binom{-4}{5}
       + 6 \cdot (-1)^1 \binom{-4}{1}
\end{align}
Use of the generalized binomial theorem finishes this off:
$$
\binom{-m}{k} = (-1)^k \binom{k + m - 1}{m - 1}
$$
for $m \in \mathbb{N}$. You get 20 as result.
