Press ▶ Play to build all kn ways to distribute n distinct items into k labeled cells, or Step ▶ to send one item at a time. Each item independently picks one of the k cells (no capacity limit, cells may be empty) — so there are k choices for each of the n items, giving k × k × … × k = kn. Same math as permutations with repetition, just framed from the items' point of view.
● BallsA Letters
n =3?
k =3?
Speed
Distribution into cells (kⁿ)
kn = 3³ = 3 × 3 × 3 = 27
Distribute n distinct items into k distinct cells. Each item independently picks one cell, with no capacity limit (cells may be empty). Since each of the n items has k independent choices, the total is k × k × ⋯ × k = kn. Same math as permutations with repetition — different framing.
Distribution into cells — an assignment of n distinct items to k labeled cells, where each item independently picks one cell. The count is kn.
Labeled cells — the cells are distinguishable, named *Cell 1, Cell 2, …, Cell k*. The same set of items split between *Cell 1* and *Cell 2* differently from how they sit in *Cell 2* and *Cell 1* gives a different distribution.
No capacity limit — any cell may receive any number of items, including zero. Cells may end up empty, full, or anything in between.
Assignment tuple $(c_1, c_2, \dots, c_n)$ — the canonical encoding: ci is the cell that item i chose. Two distributions are the same iff their tuples are identical.
Function view — every distribution is a function f:{1,2,…,n}→{1,2,…,k}, mapping each item to its cell. There are exactly kn such functions.
Item-1 destination group — the family of distributions where item 1 ends up in a specific cell. The completed section groups results by this destination; with k cells each holding kn−1 outcomes, the groups are all the same size.
Getting Started
The tool opens with n=3 items and k=3 cells. The scene splits into three areas:
• An items row at the top, captioned *ITEMS TO PLACE (n = N)*, showing the n distinct items.
• A cells row in the middle, captioned *CELLS (k = K)*, with k labeled boxes named *Cell 1* through *Cell k*.
• A completed section below, where every finished distribution is filed under the row matching which cell item 1 picked.
To run the visualization:
• Press ▶ Play to auto-build all kn distributions.
• Press Step ▶ to send one item at a time.
• Press ◀ to step backward.
• Adjust the Speed slider.
The header shows the formula kn=total alongside a live status line like *Cell c: k / kn−1* while building. Below the cells a live assignment readout shows (c1,c2,…,cn) with unknown slots marked ? as the build progresses.
The Cells
The cells are the destination boxes for each item. Five things to watch:
• Each cell is labeled *Cell 1, Cell 2, …* above the box. The labels are part of the data — *Cell 1* and *Cell 2* are different even if they end up holding the same items.
• Items stack bottom-up inside a cell as they arrive. The visual position in the stack reflects arrival order, but for counting purposes only *which items are in this cell* matters.
• No capacity limit. A cell can end up with 0, 1, 2, … any number of items up to n. The all-items-in-Cell-1 outcome is just as valid as the perfectly-spread outcome.
• When an item is in flight from its source position to a cell, a dotted guide line in the item's color traces the trajectory.
• When all n items are placed, a flash ring briefly pulses around the entire cell row, and the completed distribution is filed in the right group row below.
Below the cells, an assignment readout shows the current tuple (c1,c2,…,cn) with ? for unfilled positions, and a legend reminds you that ci is the cell item i went to.
Adjusting n and k
Two steppers in the control bar control the size:
• n sets the number of distinct items. Range 2 to 4.
• k sets the number of distinct cells. Range 2 to 4, capped per n to keep kn manageable.
The caps are:
• n=2: maximum k=4, giving 42=16 distributions.
• n=3: maximum k=4, giving 43=64 distributions.
• n=4: maximum k=3, giving 34=81 distributions.
Common combinations:
• n=3,k=2: 23=8 distributions.
• n=3,k=3: 33=27 distributions.
• n=4,k=2: 24=16 distributions.
Reducing n may cause k to clamp to the new maximum automatically. Changing either value resets the build and refreshes the formula in the header.
Grouping by Item 1's Destination
The completed section organizes distributions by which cell item 1 picked. There are exactly k rows — one per cell — and each row holds every distribution where item 1 went to that particular cell.
Unlike the variable-size groups in *partition into groups*, here all k groups have the same size:
group size=kn−1
This is because once item 1's destination is fixed, the remaining n−1 items still independently pick from all k cells — no constraint changes. So each group contributes kn−1 distributions and the total is:
k×kn−1=kn
This uniformity is the visual signature of independent choice. Compare it with the simple combination visualizer, where smallest-item groups shrink as the smallest gets larger, or with partition into groups, where group sizes depend on the box sizes. Here every group is identical in size.
Each row in the completed area has a *item 1 → Cell c* label on the left and a grid of mini cards. Each mini card shows the full assignment as k small stacked cells plus the tuple (c1,c2,…,cn) below it.
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 distribution or pausing mid-build.
• Step ▶ (Step forward) — sends one item into its chosen cell. Stop after each step to read the partial assignment tuple.
• ▶ Play / ⏸ Pause — runs the animation continuously until all kn distributions are built, then auto-pauses.
• ↺ Reset — clears the completed section and starts over from the first distribution.
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 item travel from the items row into a specific cell and stack on top of whatever is already there.
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. Best for tracking item identity at a glance as items stack inside cells and for spotting distribution patterns visually.
• Letters mode — items appear with letter labels (A, B, C, …). Best for reading off each distribution and matching the visual stack to the assignment tuple, where item A goes to cell c1, item B to cell c2, and so on.
The encoding is consistent across the items row, the cells, the flying ball, every mini distribution card in the completed grid, and the right-panel narration. Cell numbers (1, 2, 3, …) are independent of mode — cells are always numbered, regardless of how items are displayed.
Right Panel and Progress
The right panel narrates the build as it unfolds, anchored by the header *Distribution into cells (kn)* with the formula displayed across multiple lines and a reminder that this is the same math as permutations with repetition, framed from the items' point of view rather than positions to fill.
A StepRow is added for each item-1-destination group as soon as a distribution in that group starts or completes. Each StepRow shows:
• The destination as text — *Item 1 → Cell c*.
• A progress counterk/kn−1 tracking how many distributions in this group have completed.
• A short narration: *When item 1 goes to Cell c, the remaining n−1 items each still independently pick one of k cells. That gives kn−1 outcomes in this group.*
When all groups complete, every StepRow shows *done* with a checkmark, and the counter reaches *total / total*.
What Is a Distribution into Cells
A distribution into cells assigns n distinct items to k labeled cells, with each item independently choosing one cell and no capacity restriction. The count is:
kn
Equivalently, this counts:
• The number of functionsf:{1,…,n}→{1,…,k} — every item has a target, every target is a valid choice.
• The number of length-nsequences with entries from {1,…,k} — the assignment tuple (c1,…,cn) is exactly such a sequence.
• The number of ways to colorn distinguishable objects using k colors with reuse allowed.
Examples:
• Assigning 4 distinct tasks to 3 workers (any worker may get any number of tasks): 34=81 assignments.
• Sending 5 different letters to 3 different mailboxes: 35=243 sendings.
• Number of functions from a 3-element set to a 5-element set: 53=125.
For deeper coverage of the formula and its connections, see the distribution into cells section on the combinations theory page.
Deriving k^n
The cleanest derivation is the multiplication principle from the items' perspective.
Each of the n items independently picks one of k cells:
• Item 1: k choices.
• Item 2: k choices (independent of item 1).
• Item 3: k choices.
• …
• Item $n$: k choices.
Multiply n identical factors of k:
k×k×k×⋯×k=kn
The tool visualizes the equivalent decomposition: fix where item 1 goes (k ways), then ask how many ways the remaining n−1 items can be distributed independently (kn−1 ways). Every row in the completed section is one of those k item-1-destination families, all the same size.
Note the perfect symmetry: it doesn't matter which item you fix first — fixing item 2 or item n instead would give the same decomposition into k equal-size groups, just labeled differently. This is the visual signature of full independence.
Counts grow quickly: 25=32, 35=243, 55=3125. The base k and exponent n play asymmetric roles — increasing n multiplies the count by k, increasing k multiplies by a factor that itself depends on n.
Related Concepts
Permutation with repetition — the same formula nr, but with the roles of n and r swapped semantically. There, r positions independently pick from n options; here, n items independently pick from k cells. Mathematically identical: r positions ↔ n items, n options ↔ k cells.
Weak composition — distributes nidentical items into k labeled cells, with empties allowed. Formula (k−1n+k−1). Strictly smaller than kn because the items can no longer be told apart.
Strong composition — like weak composition but every cell must receive at least one item. Formula (k−1n−1).
Partition into groups — distributes n distinct items into k labeled cells of fixed sizes. Adds a hard constraint that turns kn into the multinomial coefficient.
Functions from a set to a set — the algebraic reading. Counting functions f:A→B with ∣A∣=n and ∣B∣=k gives kn, sometimes written BA.
Surjective functions — functions where every cell is hit. Counted by k!⋅S(n,k) where S(n,k) is the Stirling number of the second kind. Always at most kn.
Pigeonhole principle — when n>k, at least one cell must contain more than one item. The distribution count kn includes every such forced overlap.
Combinatorics calculator — to compute kn for arbitrary n and k, see the distribution into cells calculator.