The problem is finding the number of different solutions of the equation
![](https://latex.codecogs.com/png.latex?\bg_white r + y + g + p + b = 50)
where
![](https://latex.codecogs.com/png.latex?\bg_white r)
is the number of red balls, etc, subject to the constraints that:
Equations like this are called Diophantine equations and the number of solutions can be counted by the "stars and bars" method - neither of which is formally in any HSC course. Without the constraints, the number of combinations / solutions would simply be:
![](https://latex.codecogs.com/png.latex?\bg_white \binom{50-1}{5-1} = \binom{49}{4} = 211\ 876)
Taking into account the constraint that there must be at least 4 of each colour, and noting that the stars-and-bars approach is designed for at least one of each, we can transform using
![](https://latex.codecogs.com/png.latex?\bg_white r' = r - 3)
(and similar), so that
![](https://latex.codecogs.com/png.latex?\bg_white r')
is the number of red balls more than 3, so that the minimum value of
![](https://latex.codecogs.com/png.latex?\bg_white r')
is 1, consistent with how stars-and-bars counting works. This yields:
![](https://latex.codecogs.com/png.latex?\bg_white \begin{align*} r + y + g + p + b &= 50 \\ (r' + 3) + (y' + 3) + (g' + 3) + (p' + 3) + (b' + 3) &= 50 \\ r' + y' + g' + p' + b' &= 50 - 5 \times 3 = 35 \end{align*})
The number of solutions here is then
![](https://latex.codecogs.com/png.latex?\bg_white \binom{35-1}{5-1} = \binom{34}{4} = 46\ 376)
However, this does not account for the constraint that
![](https://latex.codecogs.com/png.latex?\bg_white r' \le 13)
, etc. We now need to count the cases where one or more colours would have too many balls, and subtract those.
Can anyone complete the solution from here?