Difficult question on combinations with repetition (number of different colored balls in three boxes) We are given a red box, a blue box and a green box, and also given 10 red balls, 10 blue balls, and 10 green balls. Balls of the same color are indistinguishable. 
Consider the following constraints:
1: No box contains a ball that has the same colour as the box. 
2: No box is empty.
Find the number of ways to put 30 balls into boxes so :
a) Constraint B is satisﬁed. 
b) Constraints A and B are satisﬁed.
 A: (I will assume that when you said constraints A and B, you meant 1 and 2 respectively.)
a) We first ignore the given constraint and count the number of ways to distribute the 30 balls among the three boxes. Using "Stars and Bars" we can distribute the red balls in
$$\binom{10+3-1}{3-1} = \binom{12}{2}$$
ways. The blue and green balls can each be distributed among the boxes in the same number of ways, so the total number of ways to distribute the thirty balls is
$${\binom{12}{2}}^3$$
This of course includes the possibility of one or two boxes being empty, so we have to subtract those. Clearly if two of the three boxes are empty, all the balls must go into one box, and there are only three ways to do that.
For the number of ways for one box [say the red one] to be empty, we can simply repeat the "Stars and Bars" method from above, but with only two boxes, which yields
$${\binom{11}{1}}^3 = 11^3$$
However, we have to be careful and realize that the above also includes the possibility of one of the two boxes being empty; this can happen one of two ways, so the actual number of ways for only the red box to be empty is
$$11^3 - 2$$
Then we have to multiply this by three to include the possibilities of the empty box being the blue or the green one.
Finally, the number of ways to distribute the thirty balls so no box is empty is
$${\binom{12}{2}}^3 - 3\left[11^3 - 2\right] - 3 \quad= \quad{\binom{12}{2}}^3 - 3\cdot11^3 + 3$$
$$\\[1ex]$$
b) We use a similar approach to part a), again ignoring the requirement that no box be empty. This time, we can distribute the red balls in
$$\binom{10+2-1}{2-1} = \binom{11}{1} = 11$$
ways, because there are only two boxes the red balls can go into. The same applies to the blue and green balls, so the total number of ways to distribute the thirty balls is $11^3$.
Like in case a), this includes the possibility of one of the three boxes being empty, but unlike case a), we no longer have the possibility of two boxes being empty [else constraint 1 would not be satisfied].
To count the number of ways one of the boxes [again, say the red one] is empty, consider that this means all the green balls MUST go into the blue box, and all the blue balls MUST go into the green box. Thus the only thing we have to count is the number of ways of distributing the red balls, and clearly there are $11$ ways to do that. Note here that we also don't need to subtract any cases, as what we said above about the blue and green boxes guarantees neither will be empty.
Finally, multiplying the above by three to include the possibilities of either the blue or the green box being empty, we find that the number of ways to distribute so that both constraints are satisfied is
$$11^3 - 3\cdot 11$$
A: I preassume that all balls must be placed in a box and that every box can contain any number of balls that does not exceed $30$.



*

*Concerning the constraint that no box contains a ball that has the same colour as the box.


The $10$ red balls must be split up in balls that are placed in the
blue box an balls that are placed in the green box.
There are $11$ possibilities for such a split up. 
Same story for blue balls and green balls, so we arrive at $11^{3}$
possibilities in total.



*

*Concerning the constraint that no box is empty.


Without constraints the $10$ red balls are split up in $3$ groups
and applying stars and bars we find $\binom{10+2}{2}=\binom{12}{2}=66$
possibilities for that.
Same story for blue balls and green balls, so we arrive at $66^{3}$
possibilities in total.
Let $T$ denote the set of all possibilities.
Let $R$ denote the set of possibilities that satisfy the condition
that the red box is empty.
Let $B$ denote the set of possibilities that satisfy the condition
that the blue box is empty.
Let $G$ denote the set of possibilities that satisfy the condition
that the green box is empty.
Then with inclusion/exclusion and symmetry we find at first hand: $$\left|R^{\complement}\cap B^{\complement}\cap G^{\complement}\right|=\left|T\right|-\left|R\cup B\cup G\right|=$$$$66^{3}-3\left|R\right|+3\left|R\cap B\right|-\left|R\cap B\cap G\right|=66^{3}-3\left|R\right|+3\cdot1-0=66^{3}-3\left|R\right|+3$$
If no balls are placed in the red box then the red balls, the blue
balls and the green balls must be split up in balls that are placed
in the blue box and balls that are placed in the green box.
This gives $\left|R\right|=11^{3}$ possibilities so the answer here
is:$$66^{3}-3\cdot11^{3}+3$$



*

*Concerning both constraints.


Denote the set of possibilities under the condition that no box contains a ball that has the same colour of the box by $T'$.
Let $R'$ denote the elements of $T'$ that have the property that no
balls are placed in the red box.
Let $B'$ denote the elements of $T'$ that have the property that no
balls are placed in the blue box.
Let $G'$ denote the elements of $T'$ that have the property that no
balls are placed in the green box.
Then with inclusion/exclusion and symmetry we find: $$\left|R'^{\complement}\cap B'^{\complement}\cap G'^{\complement}\right|=\left|T'\right|-\left|R'\cup B'\cup G'\right|=$$$$11^{3}-3\left|R'\right|+3\left|R'\cap B'\right|-\left|R'\cap B'\cap G'\right|=11^{3}-3\left|R'\right|+0-0=11^{3}-3\left|R'\right|$$
If no balls are placed in placed in the red box then all blue balls
will be placed in the green box and all green balls in the blue box.
Further there are $11$ possible split ups again for the red balls
so we end up with: $$11^{3}-3\cdot11$$ possibilities.
A: In case you can fit any number of balls in a box, and all boxes are distinguishable, each colour has $\binom{10+2-1}{10}$ possible allocations. Every allocation is unique, so you don't over count, just take the product to get the solution to 1. The rest should be easy.
For the emptiness part note you can't have 2 empty boxes. First each empty box you have $\binom{11}{10}$ choices for one colour and exactly 1 for the other too, as there's only one box available to each.
