The Mode switch toggles ● Balls (colored circles numbered 1, 2, 3 …) and A Letters (tiles A, B, C …); cells stay numbered in both. Learn more about the mode switch
n − / + sets the items from 2 to 4 and k − / + the cells from 2 to 4, capped at 3 for n=4; raising n can lower k. Learn more about adjusting n and k
▶ Play builds all kn distributions and stops at the end, Step ▶ sends one item into its cell, ◀ Back steps backward and ↺ Reset clears the completed rows. Learn more about the transport controls
The header shows kn and the total; the status line under it tracks the cell item 1 went to and ends at Complete. Learn more about getting started
Each item flies into its cell and stacks on what is there, with no capacity limit; the assignment readout fills in (c1,c2,…) as items land. Learn more about the cells
Finished distributions are filed under COMPLETED, one row per cell item 1 went to, each row holding kn−1 cards. Learn more about the item 1 groups
The right panel adds a row per destination of item 1 with its progress and the kn−1 count for the remaining items. Learn more about the right panel
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 (c1,c2,…,cn) — 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
DemoPlay all 3² distributions
Step 0 of 5
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 ◀ Back 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.
(n, k) = (3, 3), idle, frozen
Three items above three empty cells, the readout showing (?, ?, ?) — a distribution is that tuple, and the run just fills in the question marks.
The frozen frame above is the opening position: three items above three tall, empty cells, the readout showing (?,?,?). The question marks are the honest notation — a distribution is that tuple, one cell number per item, and the run's only job is to replace every ? with a choice.
Unlike the partition tool's fixed room sizes, nothing here constrains where anyone goes. Every ? has the full menu of k cells, which is why the total is a clean power — see the cells for the mechanics.
The Cells
DemoOne item at a time
Step 0 of 5
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.
(3, 3) mid-build, frozen
Items 1 and 2 stacked together in Cell 1, item 3 riding its guide to Cell 2, readout (1, 1, ?) — sharing a cell is the rule working, not breaking.
The frozen frame above catches the second distribution mid-build: items 1 and 2 stacked together in Cell 1, item 3 riding its dotted guide toward Cell 2, and the readout at (1,1,?). Two items sharing a cell is not a collision — it is the "no capacity limit" rule doing exactly what it promises.
The stack order inside a cell records arrival, not meaning: for the count, only the tuple matters. That is why the readout, not the picture, is the mathematical object — the picture is the tuple made physical, as the derivation spells out.
Adjusting n and k
DemoSteppers n and k
Step 0 of 5
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.
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.
3³ complete, frozen
Twenty-seven cards in three ruler-straight rows of nine: equal groups are the fingerprint of fully independent choices.
The frozen frame above is the default 33=27 completed: three rows of nine, ruler-straight. The equal rows are this page's counterpoint to the staircases elsewhere in the section — independence means the first choice tells you nothing about how many ways remain.
Twenty-seven cards also invite an audit of the "no constraint" claim: find (1,1,1) — everything crowded into one cell — and (1,2,3) — everything spread. Both sit in the grid with equal standing; the count plays no favorites among shapes.
Two Cells: Binary Choices
Set k=2 and every item faces the simplest possible decision: Cell 1 or Cell 2. With n=3 items, that is 23=8 distributions — the assignment tuples run through every binary string of length three, from (1,1,1) to (2,2,2).
Eight is a number with a second identity: it is the number of subsets of a three-element set. Read each distribution as "the set of items that chose Cell 1" and the eight cards become the eight subsets — empty set through full set — with Cell 2 holding each complement.
This is why 2n counts subsets: a subset is nothing but a two-cell distribution wearing set notation.
2³ complete, frozen
Eight cards, one per binary string — and one per subset of the three items, reading Cell 1 as "in" and Cell 2 as "out."
The subset reading turns this configuration into a bridge across the whole section: the combination tool counts subsets of one fixed size ((rn) of them), and summing those sizes recovers this page's total — ∑r(rn)=2n, the binomial theorem at x=y=1.
Every yes/no survey, every on/off switchboard, every include/exclude decision is a two-cell distribution. The general kn is just this picture with a longer menu.
More Cells Than Items
Set n=2,k=4 and the tool draws a scene the fixed-size partition tool never could: four cells for only two items, 42=16 distributions — and in every one of them, at least two cells stand empty.
Emptiness here is not failure but freedom: "no capacity limit" cuts both ways, and a cell that attracts nobody is as legal as a cell that attracts everyone. The sixteen cards show every pattern — the two items together in any of the four cells, or split across any ordered pair of different cells.
In function language: with a domain of 2 and a codomain of 4, no function can be surjective — the range simply runs out of elements before the codomain does.
4² complete, frozen
Sixteen cards, each leaving at least two of the four cells empty: with more cells than items, vacancy is guaranteed.
The guaranteed-empty configuration is the mirror image of the pigeonhole crowding at n>k: too many cells forces vacancy exactly as too many items forces sharing. Between the two regimes sits n=k, the only territory where every-cell-filled is even possible — those all-full distributions are the k! bijections, a vanishing minority of the kk total.
For counts that require every cell non-empty, the section offers the strong composition for identical items — and for distinct items, the surjection count in the related concepts is the answer this tool deliberately doesn't enforce.
Transport Controls
The control bar offers four transport buttons plus a speed slider:
• ◀ Back (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.
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 kitem-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.
3⁴ complete, frozen
The largest run: 81 cards, and by the pigeonhole principle every single one has some cell holding two or more items.
The frozen frame above is the page's largest run: 34=81 distributions of four items into three cells. With more items than cells, the pigeonhole principle guarantees a shared cell in every single card — scan the grid and you will find no distribution with all four items alone.
Eighty-one is also where this tool and its mirror meet: the permutation-with-repetition page shows the same 81 as 34 sequences. One enumeration, two stories — positions choosing symbols there, items choosing cells here.
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.
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, as the 81-card run shows card by card. 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.