combinations help, 18 boxes, 42 marbles, each box can hold 6 marbles. how many combinations? I am working on a scheduling algorithm for teachers taking classes, and I am working out possible run times. I have simplified the problem down to this analogy
If I had 18 boxes and 42 marbles. Each box could hold from 0 - 42 marbles. The amount of combinations would be $42^{18} = 165381614442044595841154678784 = 1.653816144 \times 10^{29}$  right?
however my problem is i have 18 boxes and 42 marbles each box can hold from 0-6 marbles how do I work out how many combinations?
 A: This isn't a complete answer but I think im on the right track.
Let $x_1, x_2, ..., x_{18}$ be the number of marbles on each box.  We know $x_1+ x_2+ ...+ x_{18}=42\hspace{5pt}where \hspace{5pt} 0\leq  x_n \leq 6$
The number of combinations for one solution to the above equation will be:
$ {{42}\choose{x_1}}{{42-x_1}\choose{x_2}}{{42-x_1-x_2}\choose{x_3}}...{{42-x_1-x_2-...-x_{17}}\choose{x_{18}}}$
From here I'm not sure how to solve it analytically. You need to add together all the possible combinations of $x_n$ that make the first equation true. If you know how to code, you could do it by brute force.
There may be a better solution that I'm missing though. Hopefully someone finds it!
A: The question is equivalent to forming all possible $42$ letter words from
$AAAAAABBBBBB........ QQQQQQRRRRRR$
And this can be solved easily by finding the coefficient of $x^{42}$ in $42!(1+x+\frac{x^2}{2!} +\frac{x^3}{3!} + ...... + \frac{x^6}{6!})
^{18}$
Wolframalpha gives a solution of 45383495753164408851516565370097827067237989942722560
If you aren't familiar with this particular generating function, you could have a look at a smaller equivalent problem explained here in a long way and using the generating function.
