[Math] In how many ways can $5$ balls of different colours be placed in $3$ boxes of different sizes if no box remains empty

combinatoricspermutations

5 balls of different colours are to be placed in 3 boxes of different sizes. Each box can hold all 5 balls. The number of ways in which we can place the balls in the boxes so that no box remains empty.

My attempt:-

First choose 3 balls to be placed in 3 boxes so that none of them remain empty in ${{5}\choose{3}}\cdot3! = 60$ ways.

Now remaining 2 balls can go into any of the 3 boxes in $3\cdot3 = 9$ ways.

Total number of ways $= 60\cdot9 = 540$.

Where am I going wrong ?

Best Answer

There are three choices for each of the five balls. Hence, if there were no restrictions, the balls could be placed in the boxes in $3^5$ ways. From these, we must exclude those distributions in which one or more of the boxes is empty.

There are $\binom{3}{1}$ ways to exclude one of the boxes and $2^5$ ways to distribute the balls to the remaining boxes. Hence, there are $$\binom{3}{1}2^5$$ ways to distribute the balls so that one of the boxes is empty.

However, we have counted those distributions in which two of the boxes are empty twice, once for each of the ways we could have designated one of the empty boxes as the excluded box. We only want to exclude them once, so we must add these cases back.

There are $\binom{3}{2}$ ways to exclude two of the boxes and one way to place all the balls in the remaining box.

Hence, the number of ways the balls can be distributed so that no box is left empty is $$3^5 - \binom{3}{1}2^5 + \binom{3}{2}1^5$$ by the Inclusion-Exclusion Principle.

Where am I going wrong?

You count each distribution in which one box receives three balls and the others receive one three times, once for each way you could place one of those three balls first.

You count each distribution in which two of the boxes receive two balls and the other box receives one four times, once for each way you could place one of the two balls in each of the two boxes with two balls first.

Three balls in one box and one ball in each of the others: There are three ways to choose which box receives three balls, $\binom{5}{3}$ ways to choose which three balls are placed in that box, and $2!$ ways to distribute the remaining balls. Hence, there are $$\binom{3}{1}\binom{5}{3}2!$$ ways to distribute the balls so that three balls are placed in the same box.

Two boxes receives two balls and one box receives one ball: There are three ways to choose which box receives only one ball and five ways to choose the ball that is placed in that box. There are $\binom{4}{2}$ ways to choose which two of the remaining four balls are placed in the smaller of the two remaining boxes. The other two balls must be placed in the remaining box. Hence, there are $$\binom{3}{1}\binom{5}{1}\binom{4}{2}$$ ways to distribute the balls so that two boxes receive two balls and one box receives one.

Observe that $$\binom{3}{1}\binom{5}{3}2! + \binom{3}{1}\binom{5}{1}\binom{4}{2} = 3^5 - \binom{3}{1}2^5 + \binom{3}{2}1^5$$

Since you counted distributions in which one box receives three balls and the others receive one three times and distributions in which two boxes receive two balls and the other receives one four times, you obtained $$3\binom{3}{1}\binom{5}{3}2! + 4\binom{3}{1}\binom{5}{1}\binom{4}{2} = \binom{5}{3} \cdot 3! \cdot 3^2$$