We can also use recurrences, where A,B,C are the number of balls of three colors:
a)
\begin{align*}
f(a,b,c) = \left\{\begin{matrix}
3-\left(\lfloor\frac{a}{A}\rfloor + \lfloor\frac{b}{B}\rfloor+\lfloor\frac{c}{C}\rfloor\right)& \text{if }A+B+C-(a+b+c) = 3\\
\dfrac{a\cdot f(a-1,b,c)+b\cdot f(a,b-1,c)+c\cdot f(a,b,c-1)}{a+b+c} & \text{otherwise}
\end{matrix}\right.
\end{align*}
b)
\begin{align*}
f(a,b,c) = \left\{\begin{matrix}
3-\left(\lfloor\frac{a}{A}\rfloor + \lfloor\frac{b}{B}\rfloor+\lfloor\frac{c}{C}\rfloor\right)& \text{if }A+B+C-(a+b+c) = 3\\
\dfrac{A\cdot f(a-1,b,c)+B\cdot f(a,b-1,c)+C\cdot f(a,b,c-1)}{A+B+C} & \text{otherwise}
\end{matrix}\right.
\end{align*}