[Math] There are n objects and n boxes, how many ways can we place the objects so exactly one box remains empty

combinatoricsinteger-partitionsprobability

A) if both objects and boxes and indistinguishable

B) if objects are indistinguishable and boxes are distinguishable

My attempt:

I know there are n! ways to but n objects into n boxes (both distinguishable).

A) I also know that to put n indistinguishable objects into n indistinguishable boxes we must count the number of partitions of n into n integers. I am unsure of how to calculate this and how to add the 1 box empty condition.

B) I know there are C(n + r − 1, n − 1) ways to place n indistinguishable objects into r distinguishable boxes. I can replace r with n. I am unsure of how to account for the 1 box empty condition here, as well.

Best Answer

If both objects and boxes are distinguishable:
There are $n$ ways to select a box that'll be empty. Since rest of the boxes will have at least 1 object each, therefore there will one box out of the $n-1$ that will have two objects in it. There are $n-1$ ways to choose this box. Further, we have ${n\choose2}$ ways to put two objects in the selected box and $(n-2)!$ ways to arrange the rest of the objects in the remaining $n-2$ boxes such that each of those boxes gets exactly $1$ object. So the number of ways will be $n(n-1){n\choose2}(n-2)!=n!{n\choose2}$

A) If both objects and boxes are indistinguishable, there will be only $1$ way of placing the objects.

B) If the objects are indistinguishable, there will be only $1$ way of placing the objects after choosing the boxes. So there are $n(n-1)={n\choose2}$ ways.


Another method when both are distinguishable:
We first select $2$ objects that will be together in the box containing $2$ objects. There are $n\choose 2$ ways to do this. We now have $1$ "double object", $1$ "empty object" and $n-2$ normal objects. Since these are obviously distinguishable, we need to place $n$ objects in $n$ boxes. So there are $n!$ ways to do this. Therefore our answer will be $n! {n\choose 2}$. This can be done similarly for (B).