Press ▶ Play to build all n! / (n₁!·n₂!·…·nₖ!) partitions of n distinct items into k labeled boxes of fixed sizes, or Step ▶ to advance one ball at a time. Cycle the partition to try different shapes.
● BallsA Letters
partition =2+2?
Speed
Partitions into labeled groups
4! / (2! · 2!) = 6
Split n distinct items into k labeled boxes with fixed sizes (n₁, n₂, …, nₖ). The boxes are distinguishable; only which items are together in a box matters — internal order within a box doesn't. Equivalent to the multinomial coefficient.
Partition into groups — a split of n distinct items into k labeled boxes of fixed sizes (n1,n2,…,nk) with n1+n2+⋯+nk=n. The count is n!/(n1!⋅n2!⋯nk!).
Multinomial coefficient — the formula above, written (n1,n2,…,nkn). Generalizes the binomial coefficient (rn) to more than two groups.
Labeled boxes — the boxes are distinguishable, named *Box A, Box B, Box C, …* in the tool. Swapping the entire contents of two boxes produces a different partition even if both boxes have the same size.
Within-box order does not matter — what counts is which items end up together in each box, not the order they appear in. Each box is treated as a set.
Partition shape — the sequence of box sizes, written like 2+2, 3+1+1, or 2+2+1. The visualizer cycles through seven curated shapes.
Item-1 destination group — the family of partitions where item 1 (the red ball) ends up in a specific box. The completed section groups results by this destination, giving k rows.
Getting Started
The tool opens with partition shape 2+2 — four items split into two boxes of two. The scene splits into three areas:
• A source row at the top showing the n available items.
• A build boxes row in the middle with k labeled boxes, each captioned *BOX A (n1), BOX B (n2), …* with the box size in parentheses.
• A completed section below, where every finished partition is filed under the row matching which box received item 1.
To run the visualization:
• Press ▶ Play to auto-build all n!/(n1!⋯nk!) partitions.
• Press Step ▶ to advance one ball at a time.
• Press ◀ to step backward through the animation.
• Adjust the Speed slider.
The header shows the multinomial formula for the current shape and a live status line such as *Item 1 in Box A: k / size*.
The Build Boxes
The build area has k separate boxes side by side, each labeled *BOX A, BOX B, BOX C, …* with the size of that box written in parentheses below the letter. What to watch:
• Box outlines in the surface color, with a stronger border that makes the boxes visually distinct from the build area as a whole.
• Dashed circle outlines inside each box mark the ni slot positions for that box.
• When a ball is in flight from the source row to a slot, a dotted guide line in that ball's color traces the trajectory. The ball may travel into any of the k boxes.
• Balls land in canonical order — the tool fills box A before box B before box C, and within each box in increasing item-id order — so equivalent partitions render the same way.
• In the source row, items already placed (or in flight) are dimmed.
• When all n slots are filled across all boxes, a flash ring briefly pulses around the entire box row, and the completed partition is filed in the right row below.
The Partition Stepper
Instead of separate n and r steppers, this tool has a partition stepper that cycles through seven curated shapes:
• 2+2 — n=4, two boxes of two. 4!/(2!⋅2!)=6 partitions.
• 3+1 — n=4, one box of three plus a singleton. 4!/(3!⋅1!)=4 partitions.
• 2+1+1 — n=4, one box of two plus two singletons. 4!/(2!⋅1!⋅1!)=12 partitions.
• 4+1 — n=5, one box of four plus a singleton. 5!/(4!⋅1!)=5 partitions.
• 3+2 — n=5. 5!/(3!⋅2!)=10 partitions.
• 3+1+1 — n=5. 5!/(3!⋅1!⋅1!)=20 partitions.
• 2+2+1 — n=5. 5!/(2!⋅2!⋅1!)=30 partitions.
Use the ◀ and ▶ buttons next to *partition =* to cycle. Each preset resets the build, refreshes the formula in the header, and rebuilds the completed section into a new set of item-1-destination rows.
Grouping by Item-1 Destination
The completed section organizes partitions by which box contains item 1 (the red ball). There are exactly k rows — one per box — and each row holds every partition where item 1 ended up in that particular box.
Group sizes are not all equal. If item 1 goes into box i (of size ni), the remaining n−1 items must fill the remaining slots — one less slot in box i, all slots in the other boxes — and there are:
n1!⋅n2!⋯(ni−1)!⋯nk!(n−1)!
ways to do so. Summing this across the k possible destinations recovers the full multinomial:
i=1∑kn1!⋯(ni−1)!⋯nk!(n−1)!=n1!⋅n2!⋯nk!n!
This is the multinomial analogue of Pascal's identity. For example with shape 2+1+1:
• Item 1 in Box A (size 2): remaining 3 items split as 1+1+1, 3!/(1!⋅1!⋅1!)=6 partitions.
• Item 1 in Box B (size 1): Box B is full, remaining 3 items split as 2+1, 3!/(2!⋅1!)=3.
• Item 1 in Box C (size 1): same as B, 3 partitions.
Total: 6+3+3=12=4!/(2!⋅1!⋅1!).
Transport Controls
The control bar offers four transport buttons plus a speed slider:
• ◀ (Step back) — walks the animation one step backward. Useful for re-examining a single partition or pausing mid-build.
• Step ▶ (Step forward) — advances one ball into one slot in the relevant box. Stop after each step to read the partial partition.
• ▶ Play / ⏸ Pause — runs the animation continuously until all multinomial partitions are built, then auto-pauses.
• ↺ Reset — clears the completed section and starts over from the first partition.
The Speed slider controls how fast play advances. At higher speeds the fly and land timings shrink proportionally; at slower speeds you can clearly see each ball travel from source into a specific box and follow the dotted guide line.
Mode Switch
The Mode switch at the start of the control bar toggles how each item is rendered:
• Balls mode (default) — items appear as colored circles. The item-1 chip in each StepRow is a red circle. Best for tracking item identity at a glance and watching the red ball flow into different boxes across rows.
• Letters mode — items appear with letter labels (A, B, C, …). The chip becomes the letter A in red. Best for reading off each partition as a set of labeled groups, like {A,C}∣{B,D}.
The encoding is consistent across the source row, the build boxes, the flying ball, every mini partition card in the completed grid, and the right-panel narration. Note the labels A, B, C, D inside the boxes (box names) are distinct from the item letters in letters mode — boxes are always named with the same A–D labels regardless of mode.
Right Panel and Progress
The right panel narrates the build as it unfolds, anchored by the header *Partitions into labeled groups* and the full multinomial formula for the current partition shape, with a reminder that boxes are distinguishable and within-box order doesn't matter.
A StepRow is added for each item-1-destination group as soon as a partition in that group starts or completes. Each StepRow shows:
• The destination as a chip and arrow — for instance, *A (red) → Box A*.
• A progress counterk/group size tracking how many partitions in this group have completed.
• A short narration of the structure: *Item 1 is placed in Box A (size 2). The remaining 3 items partition into the other boxes of sizes 1, 1, 1 (Box A needs 1 more), giving 3!/(1!⋅1!⋅1!)=6 partitions.* The formula reflects the reduced sizes after item 1 is placed.
When all groups complete, every StepRow shows *done* with a checkmark, and the counter reaches *total / total*.
What Is a Partition into Groups
A partition into groups distributes n distinct items into klabeled boxes of fixed sizes (n1,n2,…,nk) with n1+n2+⋯+nk=n. The count is the multinomial coefficient:
(n1,n2,…,nkn)=n1!⋅n2!⋯nk!n!
Two design choices are worth pinning down:
• Boxes are labeled. Swapping the entire contents of two boxes counts as a different partition, even if both boxes have the same size. So 2+2 on four items gives 6 partitions, not 3.
• Within a box, order does not matter. Each box is a set.
Examples:
• Splitting 10 players into two teams of 5 (labeled team red vs team blue): 10!/(5!⋅5!)=252 ways.
• Dealing 13 cards each to four labeled players from a 52-card deck: 52!/(13!)4≈5.36×1028 deals.
• Sorting 9 students into three labeled committees of sizes 4,3,2: 9!/(4!⋅3!⋅2!)=1260 assignments.
Note: if the boxes were unlabeled instead, you would divide by the number of permutations of equally-sized boxes, since those rearrangements no longer count separately. This tool covers the labeled case.
For deeper coverage, see the partition into groups section on the combinations theory page.
Deriving the Multinomial Coefficient
Two equivalent derivations.
By sequential choice. Fill the boxes in order:
• Choose n1 items for Box A: (n1n) ways.
• From the remaining n−n1, choose n2 for Box B: (n2n−n1) ways.
• From the remaining n−n1−n2, choose n3 for Box C: (n3n−n1−n2) ways.
• Continue until all boxes are filled.
Multiplying these binomial coefficients telescopes:
By over-counting and dividing. Arrange all n items in a sequence (n! ways), then declare that the first n1 items go in Box A, the next n2 in Box B, and so on. Within each box the internal order doesn't matter, so we have over-counted by n1!⋅n2!⋯nk!. Divide:
n1!⋅n2!⋯nk!n!
The tool visualizes the equivalent decomposition: every partition has a unique destination for item 1. Group by that destination. Summing (n−1)!/(n1!⋯(ni−1)!⋯nk!) across all k destinations reconstructs the multinomial coefficient.
Related Concepts
Simple combination — the two-group special case. C(n,r)=(r,n−rn)=n!/(r!(n−r)!).
Permutation with identical items — algebraically the same formula n!/(k1!k2!⋯), but a different scenario. There the ki are repeat counts of identical items, and the question is distinct multiset arrangements. Here the ni are box sizes, the items are all distinct, and the question is distinct box assignments.
Distribution into cells — relaxes the fixed-size constraint. n distinct items go into r labeled boxes of any size, each item picking a box independently. Formula rn.
Stirling numbers of the second kind $S(n, k)$ — the unlabeled counterpart. Counts partitions of n distinct items into k unlabeled non-empty subsets. To convert: a labeled-box partition with all distinct sizes corresponds to k! labeled versions of one unlabeled partition.
Multinomial theorem — the algebraic context: (x1+x2+⋯+xk)n expands with multinomial coefficients (n1,…,nkn) on each monomial x1n1⋯xknk.
Combinatorics calculator — to compute the multinomial coefficient n!/(n1!⋯nk!) for any partition shape, see the partition into groups calculator.