TITLE: Counting ways to distribute 7 apples and 5 pears between 4 children with restriction
QUESTION [6 upvotes]: I was given the following problem:

In how many ways $7$ apples and $5$ pears can be distributed between four kids if each child gets three fruits?

My counting is not the strongest, here is how I approached the problem: first I will distribute the pears then fill the missing spots with apples. We can use stars and bars to count the distribution of pears: $\binom{5+4-1}{4-1}=\binom 8 3=56$. We need to subtract cases when there are more than $3$ pears: $4$ (one basket with $5$ pears) and $\frac{4!}{2!}$ ($4$ pears in one basket and one in some other basket). Thus, the total number is $56-4-12=40$. Is this correct? Is there a better way to explain this problem to students?

REPLY [3 votes]: Using more powerful technique, for much more tough questions :
Lets use generating functions, lets assume that $x's$ mean apples and $y's$ mean pears, then a child can have at most $3$ apples or pears. Hence the generating function of each child is $$(x^3+ x^2y +xy^2 +y^3) = \frac{x^4 -y^4}{x-y}$$
Now , we need to find the coefficient of $x^7y^5$ in the expansion of $$(x^3+ x^2y +xy^2 +y^3)^4=\left( \frac{x^4 -y^4}{x-y} \right)^4$$
The answer is $40$.