There are $x$ balls of color red, $y$ balls of color blue and $z$ balls of color white. The white balls can be individually painted to any color (either red or blue). And there is a bag, which can be filled with red and blue balls. In how many ways can the bag be filled in such a way that the number of red balls in the bag is same as the number of blue balls?
(Note that it is not necessary to use all the balls.)
I have tried the above problem, and I can get the solution by summation of possibilities of number of red/blue balls in the bag (like compute for case 1- 1R and 1B ball, case2- 2R and 2B balls, and so on and add them up). It would be really helpful if this equation can be simplified to a single formula (or maybe a recurrence relation that can be simplified?) without requiring any summation, so that the value can be calculated in constant time.
PS: I'm sorry I really couldn't find a better title.
If $x\ge y$, you must paint $k$ of the white balls red and $k+d$ of them blue, with $d:+x-y$, for some $k$ satisfying $0\le k\le\lfloor\frac{z-d}{2}\rfloor$. The number of solutions with indistinguishable white balls is then $\sum_{k=0}^{\lfloor\frac{z-d}{2}\rfloor}\binom{z}{k}\binom{z-k}{k+d}$. This formula generalises provided we define $d:=|x-y|$.