Counting ways to distribute 7 apples and 5 pears between 4 children with restriction 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?
 A: I'll do the apples rather than the pears to illustrate the simplification I have in mind.  There are $\binom {10}{3}=120$ ways to distribute $7$ apples among $4$ kids without restriction.  If no kid can have $4$ or more apples, then after assigning $4$ of the apples to one of the kids, there are $\binom 63=20$ ways to distribute the remaining $3$ apples among the $4$ kids, so there are $4 \cdot 20=80$ disallowed combinations, meaning $40$ allowed combinations.
A: One way is by considering partitions. It is sufficient to just distribute $5$ pears among the kids; the apples are complementary.
Then consider the partitions of $5$ into atmost four parts such that no part is larger than $3$. These can be listed easily

*

*$(3,2,0,0)$

*$(3,1,1,0)$

*$(2,2,1,0)$

*$(1,1,1,2)$
First item means one kid gets $3$ pears, second gets $2$ and other two get none. Others are similar.
Since the kids are distinct, total contribution is (in order)
$$\binom{4}{1}\binom{3}{1}+ \binom{4}{1}\binom{3}{2} + \binom{4}{1}\binom{3}{2} + \binom{4}{1}=40$$
EDIT :
A shortcut is to realize the list has three partitions of type $aabc$ and one of type $aaab$. Hence $3\cdot \frac{4!}{2!}+4=40$
A: 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$.
