Ball picking with a few twists Suppose I had a finite number of balls, say a total of $k$, where $k$ is a multiple of $6$. Each ball belongs to one of $n$ different groups, by color. If I know the number of balls that belong to each of the $n$ different color groups is it possible to determine, analytically, the feasibility of mixing and matching balls to create groups of $6$, with no more than $2$ colors represented in any group? What about in the case where instead of $6$ and $2$, these quantities are variable?
I'm at a loss at how to determine if this is feasible analytically. I think I could write code to iterate through and find any feasible combinations, but I'd like to avoid that if it's possible. Can anyone help?
 A: This is awfully late, but I hope it will be useful nonetheless.  I will restate the problem to be sure I understand what you are asking.
Let $g$, $m$ and $s$ be positive integers.  Given a set $S$ of $gs$ variously-colored objects, a necessary and sufficient condition that $S$ can be partitioned into $s$ $g$-sets, none of which contains more than $m$ objects of the same color, is that no color class contain more than $ms$ objects.
Necessity is clear.  For sufficiency, consider the following algorithm.  Call a color class "excessive" if it contains more than $m(s-1)$ objects.  Construct a $g$-set $G$ by first transferring $|E|-m(s-1)$ objects from each excessive set $E$ to $G$.  If there are fewer than $g$ elements in $G$, the remaining elements can be chosen arbitrarily.  Now apply the algorithm recursively to the remaining objects, with $s$-1 in place of $s$.
To justify the algorithm, we must show that in order to eliminate the excessive sets, no more than $g$ elements must be transferred to $G$.  Suppose there are $k$ color classes.  Since each class contains at most $ms$ elements, we have $msk \leq gs$, or $mk \leq  g$.  The number of "excessive" elements is $\Sigma max(c_i-m(s-1))$ where $c_i$ is the number of elements in color class $i$, and the sum is taken over all the color classes.  But $c_i \leq  ms$ so $\Sigma max(c_i-m(s-1)) \leq  \Sigma m = mk \leq  g.$    
