No adjacent empty boxes with PIE

*PIE = inclusion-exclusion

How many ways are there to distribute 10 balls into 5 distinct boxes such that no two adjacent boxes are empty?

Note: the same question statement.

I believe the question statement is equivalent to 'no empty boxes should be adjacent'. I have attempted this with PIE.

Let the set $$A_i$$ represent the arrangements where $$(i+1)$$ empty boxes are adjacent. The value required to be subtracted should be $$|A_1 \cup A_2 \cup A_3 \cup A_4|=\sum{|A_1|} - \sum{|A_1 \cap A_2|} + \sum{|A_1 \cap A_2 \cap A_3|} - 0$$ as there is no possible arrangement where $$4+1 = 5$$ boxes are empty.

$$|A_1 \cup A_2 \cup A_3 \cup A_4| = 4\cdot \binom{10+3-1}{3-1} - 3\cdot \binom{10+2-1}{2-1} + 2\cdot \binom{10+1-1}{1-1}$$ Subtracting this from $$\binom{14}{4}$$ gives $$768$$. However, the answer is 771. Clearly, the quantity I'm subtracting is a little larger. What cases am I overcounting while subtracting?

• I am not sure if one would consider this as a duplicate of the linked question.
– zxen
Mar 17 at 8:35
• Since you are asking how to correct your approach to the problem, your question is not a duplicate of the linked question. Mar 17 at 10:18

You’re not counting the three cases with four empty bins that form two pairs of adjacent empty bins correctly.

The case where all balls are in the central bin is counted twice (in the first term) instead of once.

The two cases where all the balls are in one of the outer bins are each counted three times in the first term, twice in the second term and once in the third term, for a total of twice instead of once.

This is because you don’t have a coherent setup for inclusion–exclusion. The four conditions are that none of the four pairs of adjacent bins must both be empty. In standard inclusion–exclusion, you then have to consider all possible intersections between these pairs. It’s more efficient, however, to use Möbius inversion on the poset of inadmissible arrangements. Then each adjacent pair is weighted with $$-1$$, each adjacent triple is weighted with $$-(1+-1+-1)=1$$, each adjacent quadruple is weighted with $$-(1+-1+-1+-1+1+1)=0$$ and the configuration with two adjacent pairs on the outside is weighted with $$-(1+-1+-1)=1$$, so the total is

$$\binom{10+5-1}{5-1}+4\cdot(-1)\cdot\binom{10+3-1}{3-1}+3\cdot1\cdot\binom{10+2-1}{2-1}+1\cdot\binom{10+1-1}{1-1}=771\;.$$

• Thanks for pointing out my mistake, though this seems a little above my pay grade :p
– zxen
Mar 17 at 11:01
• @zxen: OK, but consider learning about Möbius inversion at some point when you feel up to it. As you can see when you compare this answer to the accepted answer that uses standard inclusion–exclusion, it often requires considerably less bookkeeping. Mar 17 at 11:02
• Thank you, yet again! Mar 17 at 11:22

Your approach of excluding arrangements where $$i + 1$$ empty boxes are adjacent fails to exclude cases in which disjoint pairs of empty boxes appear.

Let's define $$A_i$$ to be the case in which adjacent boxes $$i$$ and $$i + 1$$ are empty.

As you observed, if there were no restrictions, the number of ways of distributing $$10$$ indistinguishable balls into five distinct boxes is the number of solutions of the equation $$x_1 + x_2 + x_3 + x_4 + x_ 5 = 10$$ in the non-negative integers, which is $$\binom{10 + 5 - 1}{5 - 1} = \binom{14}{4}$$

From these, we must exclude those cases in which a pair of adjacent boxes is empty. By the Inclusion-Exclusion Principle, the number of cases in which a pair of adjacent boxes is empty is $$|A_1 \cup A_2 \cup A_3 \cup A_4| = \sum_{i = 1}^{4} |A_i| - \sum_{1 < \leq i < j \leq 4} |A_i \cap A_j| + \sum_{1 \leq i < j < k \leq 4} |A_i \cap A_j \cap A_k| - |A_1 \cap A_2 \cap A_3 \cap A_4|$$

$$|A_1|$$: If boxes $$1$$ and $$2$$ are empty, then the $$10$$ indistinguishable balls must be distributed to the remaining three boxes, which can be done in $$\binom{10 + 3 - 1}{3 - 1} = \binom{12}{2}$$ ways.

By symmetry, $$|A_1| = |A_2| = |A_3| = |A_4|$$.

$$|A_1 \cap A_2|$$: This means boxes $$1, 2,$$ and $$3$$ are empty. Thus, the $$10$$ indistinguishable balls must be distributed to the remaining two boxes, which can be done in $$\binom{10 + 2 - 1}{2 - 1} = \binom{11}{1}$$ ways.

By symmetry, $$|A_1 \cap A_2| = |A_2 \cap A_3| = |A_3 \cap A_4|$$.

$$|A_1 \cap A_3|$$: This means boxes $$1$$ and $$2$$ and boxes $$3$$ and $$4$$ are empty. Thus, the $$10$$ indistinguishable balls must be distributed to the remaining box, which can be done in one way.

By symmetry, $$|A_1 \cap A_3| = |A_1 \cap A_4| = |A_2 \cap A_4|$$.

$$|A_1 \cap A_2 \cap A_3|$$: This means boxes $$1, 2, 3,$$ and $$4$$ are empty. The remaining $$10$$ balls can be distributed to the remaining box in one way.

By symmetry, $$|A_1 \cap A_2 \cap A_3| = |A_2 \cap A_3 \cap A_4|$$.

$$|A_1 \cap A_2 \cap A_4|$$: This means boxes $$1$$ and $$2$$ are empty, boxes $$2$$ and $$3$$ are empty, and boxes $$4$$ and $$5$$ empty, so all five boxes would have to be empty, which is not possible since we must distribute $$10$$ balls to the five boxes. Thus, $$|A_1 \cap A_2 \cap A_4| = 0$$.

By symmetry, $$|A_1 \cap A_2 \cap A_4| = |A_1 \cap A_3 \cap A_4|$$.

$$|A_1 \cap A_2 \cap A_3 \cap A_4|$$: This means all five boxes would have to be empty, which is not possible since we must place $$10$$ balls in the boxes. Thus, $$|A_1 \cap A_2 \cap A_3 \cap A_4| = 0$$.

Therefore, by the Inclusion-Exclusion Principle, the number of admissible arrangements is $$\binom{14}{4} - \binom{4}{1}\binom{12}{2} + \binom{3}{1}\binom{11}{1} + \binom{3}{1}\binom{10}{0} - \binom{2}{1}\binom{10}{0} = 771$$