I have adapted this question from this question, I don't fully understand the answers given there/ Understanding distribution using Stirling number of the second kind inclusion exclusion approach
Problem
I want to distribute $n=3$ distinguishable items to $r=3$ distinguishable groups such that
- repetition of items is not allowed
- each group contains one or more items.
Solution
We follow inclusion-exclusion principle which, in turn, takes form of Stirling number of second kind.
$3^3=27$ ways to distribute $3$ items to $3$ groups such that $3$ groups can contain zero or more items.
(Subtract) $2^3\times\binom{3}{1}=24$ ways to distribute $3$ items to $2$ groups such that $2$ groups can contain zero or more items (i.e., $1$ group is guaranteed to be empty).
(Add) $1^3\times \binom{3}{2}=3$ ways to distribute $3$ items to $1$ group such that $1$ group can contain zero or more items (i.e., $2$ groups are guaranteed to be empty).
Final answer $=27-24+3=6$. These six distributions corresponds to following distributions:
| Group 1 | Group 2 | Group 3 |
-------------------------------
| 1 | 2 | 3 |
| 1 | 3 | 2 |
| 2 | 1 | 3 |
| 2 | 3 | 1 |
| 3 | 1 | 2 |
| 3 | 2 | 1 |
Q1.
Does the table below correctly list all 27 possibilities?
| | Group 1 | Group 2 | Group 3 |
|----|---------|---------|---------|
| 1 | 123 | | | 123 in one group
| 2 | | 123 | |
| 3 | | | 123 |
------------------------------------
| 4 | 12 | 3 | | 12 in one group
| 5 | 12 | | 3 |
| 6 | 3 | 12 | |
| 7 | | 12 | 3 |
| 8 | | 3 | 12 |
| 9 | 3 | | 12 |
------------------------------------
| 10 | 23 | 1 | | 23 in one group
| 11 | 23 | | 1 |
| 12 | 1 | 23 | |
| 13 | | 23 | 1 |
| 14 | | 1 | 23 |
| 15 | 1 | | 23 |
------------------------------------
| 16 | 13 | 2 | | 13 in one group
| 17 | 13 | | 2 |
| 18 | 2 | 13 | |
| 19 | | 13 | 2 |
| 20 | | 2 | 13 |
| 21 | 2 | | 13 |
------------------------------------
| 22 | 1 | 2 | 3 | All digits/items in different groups
| 23 | 1 | 3 | 2 |
| 24 | 2 | 1 | 3 |
| 25 | 2 | 3 | 1 |
| 26 | 3 | 1 | 2 |
| 27 | 3 | 2 | 1 |
Q2.
How so these lines to the (24 &3) correspond to?
Does the 3 correspond to the first three lines?
Does the 24 correspond to lines 4 to 27?
Q3. Where does that $24$ come from?
- The first part is because there are 3 ways to exclude one bin = 3
- I am struggling to understand the groups of eight though can someone please explain how they are formed?