5

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?

Stephen
  • 719
Aleddd
  • 61
  • So the boxes and marbles are all different? – Asinomás Apr 15 '15 at 23:58
  • yes all completely different entities

    if it helps the actual problem is i have 18 teachers and 42 classes that need to be taught. classes do not overlap. each teacher can only take 6 classes

    – Aleddd Apr 16 '15 at 00:01
  • One final question, should we count arrangements in which some boxes end up being empty? – Asinomás Apr 16 '15 at 00:02
  • yes..

    i dont really under stand how that would change the answer .. 2 boxes, 1 marble ..

    combinations would be ? .. box1 - 1marble .. box2 - 0marble .. or .. box1 - 0marble .. box2 - 1marble ..

    2 combinations as the marble has to be in one box?

    – Aleddd Apr 16 '15 at 00:06
  • sorry if i am failing to get this concept. i build computer programs rather being a mathematician – Aleddd Apr 16 '15 at 00:08
  • @Aleddd the number $42^{18}$ is a good start. To make a fix to the overcounting, we can then get rid of all "bad" choices. We will get rid of all possibilities where the first teacher was overloaded with classes, then all the possibilities where the second teacher was overloaded, etc... but noting that some of those we got rid of twice (such as where both first and second teachers were overloaded), so we add those back in. See inclusion-exclusion principle – JMoravitz Apr 16 '15 at 00:10
  • @JMoravitz are you proposing we do inclusion exclusion all the way or only a few iterations? – Asinomás Apr 16 '15 at 00:12
  • @TheEmperorofIceCream My proposed solution will require 6 "iterations" (if that is what you call it) since it is possible for six teachers to be given 7 classes each with the remaining 12 teachers being given no classes. – JMoravitz Apr 16 '15 at 00:14
  • If I understand correctly the OP wants to find a function in terms of the number of marbles. I think your approach is good, I suggest you work it out, we will probably get something of exponential growth order but I don't know which will be the base for the exponent. – Asinomás Apr 16 '15 at 00:17
  • As for which is the base and exponent, I hadn't caught the mistake earlier, but for each class we choose a teacher to teach it, there should be $18^{42}$, not $42^{18}$ choices without restriction on classload. As for the specific sums I'm hitting, due to the marbles all being distinct, it seems to require case-by-case analysis within the sums themselves. (E.g. for "teacher 1 is overloaded", it might have been from having exactly 7 classes or exactly 8 classes or...) Hopefully there is an easier approach other than brute force program writing, but my approach is seemingly quite tedious. – JMoravitz Apr 16 '15 at 00:28

2 Answers2

0

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!

Loocid
  • 335
0

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.