Distribution Problems (Balls and Boxes)
Almost every counting problem in combinatorics can be viewed as distributing objects (balls) into groups (boxes). To choose the right formula without hesitation, always ask two decisive questions first:
- Are the objects distinct or identical?
- Are the boxes distinct (distinguishable) or identical (indistinguishable)?
Within each of these four quadrants, the answer also depends on whether boxes may remain empty, must be non-empty, or have fixed capacities—and whether the order of objects inside each box matters. Keep this four-quadrant roadmap in mind as we derive each case systematically:

1. Distribution of Distinct Objects into Distinct Boxes§
Suppose we have distinct objects and distinct boxes—imagine putting numbered stickers Box 1, Box 2, ..., Box k on them so every box is uniquely identifiable.
Case A: Order Inside Each Box Does Not Matter§
1. Each box can contain any number of objects (empty boxes allowed): A box may stay completely empty, or a single box may receive all objects. Each of the distinct objects independently chooses any one of the boxes (Box 1, Box 2, ..., or Box k). By the Multiplication Principle:
2. Each box must contain at least one object (): Now no box may be empty. Apply the Principle of Inclusion–Exclusion (Section 08):
Let be all unrestricted distributions, and let () be the set of distributions in which Box r is empty. We want none of the boxes to be empty, i.e., .
- If particular boxes are forced to stay empty, all objects must be placed into the remaining boxes in ways, and there are ways to choose those empty boxes.
By PIE:
3. Each box has a fixed capacity (): Suppose Box 1 must receive exactly objects, Box 2 exactly objects, ..., and Box k exactly objects, where .
- Choose objects out of for
Box 1in ways. - Choose objects from the remaining for
Box 2in ways. - Continue until the last objects go to
Box kin way.
Multiplying and canceling consecutive factorials produces the exact same multinomial formula we met in MISSISSIPPI (Section 06):
Case B: Order Inside Each Box Also Matters (Bank Cash Counters)§
Now add one further condition: the objects placed inside each box are also arranged in order—like distinct customers forming queues at distinct bank cash counters.
1. Each counter may have any number of customers (empty queues allowed): In Section 03, we counted this using the rising factorial: Person has choices, Person has , ..., and Person has , giving:
We can also derive this visually using identical wooden wedges (analogous to binary strings): arrange all distinct people and identical red wooden wedges in one long row. The wedges slice the row into ordered queues—the segment before the first wedge goes to Counter in that exact order, the segment between the first and second wedges goes to Counter , and so on!

We are permuting items in which wedges are identical, giving ways.
2. Each counter must have at least one customer (): Using wooden wedges, a counter is empty if and only if two wedges sit next to each other or a wedge sits at either end of the line. Therefore:
- Arrange all distinct customers in a single row in ways.
- This creates interior gaps between consecutive customers. Choose of these gaps to insert the identical wedges in ways.
By the Multiplication Principle:
3. Each counter has a fixed queue length (): Here the positions of the wedges are completely fixed by the required capacities—only the people permute among the ordered slots, giving simply ways.
2. Distribution of Identical Objects into Distinct Boxes§
Now suppose we have identical objects (such as identical oranges) and distinct boxes (Box 1, ..., Box k). Because the oranges are indistinguishable, only the number of oranges in Box i matters, where:
This is identical to the integral equation solved in Section 07 (Stars and Bars):
- Each box may contain any number of objects ():
- Each box must contain at least one object (, ):
3. Distribution of Distinct Objects into Identical Boxes§
Before counting distributions into identical boxes, pause and make sure you know when boxes are truly identical.
When Are Two Boxes Truly Identical?
Boxes are identical only if we have no way to distinguish one from another—no labels, no distinct spatial positions, and no different capacities! For instance, a box of capacity is automatically distinguishable from a box of capacity . Likewise, four rows of chairs in a classroom may all have the exact same capacity, yet they are distinct because Row (front), Row , Row , and Row (back) occupy different physical locations in the room.
A. Identical Boxes of Equal Fixed Capacity§
Suppose we distribute distinct objects into identical boxes, each having the exact same fixed capacity of objects.
To see the effect of removing box labels, take distinct objects and identical boxes of capacity . Look at one single distribution into identical boxes: .
If we now attach three distinct stickers—Box 1, Box 2, and Box 3—onto these three boxes, we can place the stickers in different ways, turning one identical-box distribution into distinct-box distributions:

In general, let be the number of distributions of distinct objects into identical boxes of capacity . For every such distribution, attaching distinct box stickers in ways generates all distinct-box distributions:
Remember the simple rule: when boxes of equal capacity are identical instead of distinct, divide by .
Example 1 (Handshakes vs. Numbered Tables): At a party of guests, all guests divide into pairs. In how many ways can this happen if: (a) they simply pair up to shake hands, (b) they sit in pairs at tables placed around the banquet hall?
Solution:
(a) Forming handshake pairs: Each pair is an unlabeled group of capacity —all groups are identical! Thus:
(b) Sitting in pairs at tables in the hall: Now each table is distinguishable by its physical position in the hall (near the entrance, near the stage, etc.), so the boxes are distinct! We do not divide by :
B. Mixed Fixed Capacities§
Suppose there are no labels on the boxes, yet some boxes share one capacity and other boxes share a different capacity—for example, boxes of capacity and boxes of capacity (total objects ).
The boxes of capacity are identical to one another (divide by ), and the boxes of capacity are identical to one another (divide by ), while a -object box can never be confused with a -object box. Thus the number of distributions is:
C. Arbitrary Non-Empty Groups: Stirling Numbers of the Second Kind§
Now drop fixed capacities completely: suppose we wish to partition distinct objects into non-empty identical (unlabeled) groups of any non-zero sizes.
To appreciate the subtlety, divide distinct objects into non-empty unlabeled groups by direct enumeration:
There are ways in total. Do not let your brain treat the left group as "Group 1" and the right group as "Group 2"! If you did, you would think swapping and creates an eighth way. Because the groups have no names, and are the exact same partition.
Definition (Stirling Number of the Second Kind): Denoted (or ), the Stirling number of the second kind is the number of ways to distribute distinct objects into non-empty identical boxes ().
Let us calculate key special cases directly from first principles:
- : All objects go into the single box.
- : Each object sits alone in its own box.
- : Temporarily name the two boxes Group I and Group II. Each of the objects has choices ( ways); subtracting the cases where one box is empty leaves distributions into labeled groups. Removing the two labels divides by , giving:
(Checking : , matching our enumeration!)
- : To split objects into non-empty groups, exactly one group must contain a pair of objects while the remaining groups are singletons. Choose the pair in ways.
- : Splitting objects into non-empty groups occurs in two disjoint size patterns:
- One group of size and singletons: Choose the objects in ways.
- Two groups of size and singletons: Choose objects in ways and divide them into identical pairs in ways, giving ways.
Theorem (Explicit PIE Formula for ): Attaching distinct labels to the non-empty identical boxes yields all non-empty distributions into distinct boxes. By the Division Principle:
Theorem (Recurrence Relation for ): For all :
Combinatorial Proof: Single out one specific object among the objects. In any partition of the objects into non-empty unlabeled groups, either:
- forms a singleton group by itself: The remaining objects must be partitioned into non-empty groups, which can be done in ways.
- shares a group with at least one other object: First partition the other objects into non-empty groups in ways. Because those groups now hold distinct objects, they are distinguishable! Hence has choices of which group to join, giving ways.
Adding the two disjoint cases proves .
Here are the first five rows of the Stirling triangle built directly from this recurrence:
| Row Sum | ||||||
|---|---|---|---|---|---|---|
Bell Numbers (Empty Identical Boxes Allowed)§
If distinct objects are placed into identical boxes where empty boxes are allowed, the number of occupied boxes can be , yielding ways.
When , this sum counts the total number of partitions of an -element set into any number of non-empty blocks. This famous sequence is the -th Bell Number, :
(As we will see in Section 10, also counts the exact number of equivalence relations on an -element set!)
4. Distribution of Identical Objects into Identical Boxes (Integer Partitions)§
In the fourth and final quadrant, both the objects and the boxes are identical. Neither object identities nor box order matter—only the sorted multiset of box sizes distinguishes one distribution from another!
Definition (Integer Partition): Writing a positive integer as a non-increasing sum of positive integers:
is called an integer partition of into parts, and the number of such partitions is denoted .
- Each of identical boxes non-empty: ways.
- Empty boxes allowed: ways (partitions into at most parts). When , this is the total partition function .
No simple closed-form formula exists for or ; for small , list non-increasing tuples systematically.
Example 2: In how many ways can identical marbles be distributed into identical bowls if: (a) no bowl is empty, (b) bowls may be empty?
Solution:
(a) Non-empty (): List all non-increasing triples of positive integers summing to : , , and . Thus .
(b) Empty bowls allowed ():
- non-empty bowl: way.
- non-empty bowls: ways.
- non-empty bowls: ways from part (a).
Total ways .
Master Summary of Distribution Problems§
| Objects () | Boxes () | Empty Boxes Allowed | Every Box Non-Empty () |
|---|---|---|---|
| Distinct | Distinct (unordered inside) | ||
| Distinct | Distinct (ordered inside) | ||
| Identical | Distinct | ||
| Distinct | Identical | ( if ) | |
| Identical | Identical | ( if ) |
Mark this section complete when you have worked through its proofs.