I am having a difficult time understanding how to approach this problem. Suppose I have $6$ total slots and $5$ balls. Now, I assign the balls at random to the slots. What is the probability that no slot will contain more than two balls?

My approaches so far:

I recognized that $\binom{5+(6-1)} 5$ ($10$ choose $5$) represents the total combinations per the combinations with repetitions formula.

Next, I realized that maybe I can find the probability a slot has exactly $5$, $4$, $3$ balls in one spot, then take $1$ - the sum of those probabilities.

The correct answer is around $80\%$ so I am way off with this approach. Do you guys have any idea? Thanks!


First, count the number of integer solutions to the equation $$x_1+\ldots+x_6=5$$ with $0\le x_i\le 2$, then calculate the number of integer solutions to that equation with only $0\le x_i$, and finally divide these two.

How can one do that? This is well explained in this answer.

(By the way, the correct answer is exactly 50%)

  • $\begingroup$ Is there a more intuitive, non stars and bars way of doing this problem? I am teaching an undergraduate class, this appeared on an earlier midterm and it embarrasses me I cannot do it without more advanced techniques. Thanks! $\endgroup$ – user123276 Jan 23 '14 at 12:24

Without the restriction of no more than 2 balls per slot, there are exactly as many ways as there are functions $$ f : [5] \to [6], $$ and there are exactly $6^5 = 7776$ such functions.

With the restriction that we don't want more than 2 balls per any slot, I would probably break it into the cases of 1) at most one ball per slot, or 2) at least one slot has 2 balls.

The first case contains exactly $6!=720$ ways (choose the left-over slot, then put the 5 balls in the remaining 5 slots).

For the second case, we have to choose which slots get exactly 2 balls: There could be either 1 or 2 such slots with exactly two balls.

Further subcases:

Exactly 1 slot gets 2 balls: Choose it, choose the two balls to put in, then distribute 3 balls among 4 slots. There are $$ \begin{pmatrix}6 \\ 2\end{pmatrix}\begin{pmatrix} 5 \\ 2\end{pmatrix}\begin{pmatrix} 4 \\ 1\end{pmatrix}3! = 3600 $$ ways to do this.

Exactly 2 slots get 2 balls: Choose them, their balls, then put remaining ball in one of 4 remaining slots, for a total of

$$\begin{pmatrix}6 \\ 2\end{pmatrix} \cdot 2! \cdot \begin{pmatrix}4 \\ 2\end{pmatrix} \begin{pmatrix}4 \\ 1\end{pmatrix}= 720$$ ways.

So the probability I found is $5040/7775 \approx 65$%. Clearly my answer doesn't agree with the one given by Hanz, perhaps someone will be able to point out the error I've made. I would like to say this approach is slightly more intuitive, although evidently more prone to errors!

  • 1
    $\begingroup$ I have not checked the details of the computation, but your approach is the right one, and Stars and Bars is not. The problem with Stars and Bars is that not all of the solutions of the equation $x_1+\cdots +x_6=5$ are equally likely. $\endgroup$ – André Nicolas Jan 23 '14 at 15:22
  • $\begingroup$ The difference between our approaches is caused by our different understanding of the question. If you assume the balls are identical, then without the restriction you don't have $6^5$ partitions, but instead only ${10\choose 5}$ partitions. Where I come from, we usually think of balls as identical, unless explicitly mentioned otherwise. $\endgroup$ – Bach Mar 20 '14 at 10:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.