I have $10$ indistinguishable cars , $12$ indistinguishable balls, $14$ indistinguishable teddy bears.I want to distribute them to $3$ different children in a kindergarten such that each child will take exactly $7$ toys.How many distributions are there?
$\mathbf{\text{My attempt:}}$ First of all, I thought that it can be solved by generating functions easily. However, the process became suddenly cumbersome.
If each child will take exactly $7$ toys , then we need $21$ toys in total. For example , $10$ cars, $6$ balls and $5$ teddy bears can be a sample. By using this information, I decided to use generating functions such that if a child take exactly $7$ toys, then his generating function form is $$(x^7+y^7+z^7+x^6y+x^6z+x^5y^2+x^5yz+…+yz^6)$$ where $x,y,z$ represents cars, balls and teddy bears, respectively. As you count by combination with repetition, there are $\binom{7+3-1}{7}=36$ terms in the tuple.
Because of there are $3$ children , we will deal with $$(x^7+y^7+z^7+x^6y+x^6z+x^5y^2+x^5yz+…+yz^6)^3$$
However, there is a problem for me. Calculating the coefficients for each possible selection is very cumbersome. For example, we said that one of the possible toy selections of $21$ of $36$ is $10$ cars, $6$ balls and $5$ teddy bears. In that sample, we should find $$[x^{10}y^6z^5](x^7+y^7+z^7+x^6y+x^6z+x^5y^2+x^5yz+…+yz^6)^3$$
As you realize there are many other toy selections out of $36$, for example $5$ cars, $8$ balls and $8$ teddy bears is an another sample.
I want you guys to handle this cumbersome selection process. How can I find the all coefficients of this generating function for all possibilities?
Please do not suggest using a computer algorithm. I am here to see a mathematical approach I could apply to my problem. What's more, if you have another approach, feel free and share it with me. I am open to another methods.
Best Answer
Method 1
Instead of using variables for the toys, use variables for the kids. This is the right idea since there is only way to satisfy the kids, $(7,7,7)$, while there are many ways to satisfy the toys.
Let $$ F_{\text{car}}(x,y,z)=\sum_{\substack{i,j,k \,\ge \,0,\\ i+j+k\,\le\, 10}} x^iy^jz^k $$ be the generating function which describes all ways to distribute the cars to the kids. Define $F_{\text{ball}}$ and $F_{\text{teddy}}$ similarly, where $10$ is replaced with $12$ and $14$. Then $$ \text{# ways}=[x^7y^7z^7](F_{\text{car}}\times F_{\text{ball}}\times F_{\text{teddy}}) $$
Method 2
Here is an equivalent version of your problem. You have $10+12+14=36$ identical tokens, and $12$ urns. The urns are laid out in a $4\times 3$ grid. Three of the rows correspond to children, while the last row is a slack row that represents the leftover toys no child receives. Each column corresponds to a toy. The equivalent problem is:
Since there are now six target totals to keep track of, we need six variables. I will use $x,y,z$ for the children again, and $a,b,c$ for the teddy, ball, and car respectively. Since there are $12$ urns, we need twelve generating functions. The generating functions are summarized in the below table.
The final answer is the coefficient of $x^7y^7z^7a^{14}b^{12}c^{10}$ in the product of all twelve functions in this table.
For example, the generating function for urn for child $1$ and teddy is $$1/(1-ax)=1+ax+a^2x^2+a^3x^3+\dots$$ Choosing a monomial from this series is equivalent to choosing the number of tokens that go into the urn in the child $1$ row and teddy column. If you put $n$ tokens in that urn, it is equivalent to choosing $a^nx^n$, which contributes $n$ to the quota of $x^7$, and contributes $n$ to the quota of $a^{14}$.
Computation
As a sanity check, we should see if these methods agree. The following Mathematica code indeed confirms a common answer of $35{,}336$ for both methods. The second method is much faster; the first took $30$ seconds on my machine, the latter only half a second.