Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools


Distribution into Cells


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
3³ = 27Press Play or Step to beginITEMS TO PLACE (n = 3)123CELLS (k = 3)Cell 1Cell 2Cell 3assignment: (?, ?, ?)(item 1 → cell c₁, item 2 → cell c₂, …)Each of n = 3 items independently picks 1 of k = 3 cells:3³ = 3 × 3 × 3 = 27
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.





Key Terms



Key Terms

Distribution into cells — an assignment of nn distinct items to kk labeled cells, where each item independently picks one cell. The count is knk^n.

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: cic_i is the cell that item ii 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}f: \{1, 2, \dots, n\} \to \{1, 2, \dots, k\}, mapping each item to its cell. There are exactly knk^n 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 kk cells each holding kn1k^{n - 1} outcomes, the groups are all the same size.

Getting Started

The tool opens with n=3n = 3 items and k=3k = 3 cells. The scene splits into three areas:

• An items row at the top, captioned *ITEMS TO PLACE (n = N)*, showing the nn distinct items.

• A cells row in the middle, captioned *CELLS (k = K)*, with kk 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 knk^n distributions.

• Press Step ▶ to send one item at a time.

• Press to step backward.

• Adjust the Speed slider.

The header shows the formula kn=totalk^n = \text{total} alongside a live status line like *Cell c: kk / kn1k^{n-1}* while building. Below the cells a live assignment readout shows (c1,c2,,cn)(c_1, c_2, \dots, c_n) 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 00, 11, 22, … any number of items up to nn. 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 nn 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)(c_1, c_2, \dots, c_n) with ?? for unfilled positions, and a legend reminds you that cic_i is the cell item ii went to.

Adjusting n and k

Two steppers in the control bar control the size:

n sets the number of distinct items. Range 22 to 44.

k sets the number of distinct cells. Range 22 to 44, capped per nn to keep knk^n manageable.

The caps are:

n=2n = 2: maximum k=4k = 4, giving 42=164^2 = 16 distributions.

n=3n = 3: maximum k=4k = 4, giving 43=644^3 = 64 distributions.

n=4n = 4: maximum k=3k = 3, giving 34=813^4 = 81 distributions.

Common combinations:

n=3,k=2n = 3, k = 2: 23=82^3 = 8 distributions.

n=3,k=3n = 3, k = 3: 33=273^3 = 27 distributions.

n=4,k=2n = 4, k = 2: 24=162^4 = 16 distributions.

Reducing nn may cause kk 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 kk 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 kk groups have the same size:

group size=kn1\text{group size} = k^{n - 1}


This is because once item 1's destination is fixed, the remaining n1n - 1 items still independently pick from all kk cells — no constraint changes. So each group contributes kn1k^{n - 1} distributions and the total is:

k×kn1=knk \times k^{n - 1} = k^n


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 kk small stacked cells plus the tuple (c1,c2,,cn)(c_1, c_2, \dots, c_n) 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 knk^n 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 c1c_1, item B to cell c2c_2, 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 (knk^n)* 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 counter k/kn1k / k^{n-1} tracking how many distributions in this group have completed.

• A short narration: *When item 1 goes to Cell c, the remaining n1n - 1 items each still independently pick one of kk cells. That gives kn1k^{n-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 nn distinct items to kk labeled cells, with each item independently choosing one cell and no capacity restriction. The count is:

knk^n


Equivalently, this counts:

• The number of functions f:{1,,n}{1,,k}f: \{1, \dots, n\} \to \{1, \dots, k\} — every item has a target, every target is a valid choice.

• The number of length-nn sequences with entries from {1,,k}\{1, \dots, k\} — the assignment tuple (c1,,cn)(c_1, \dots, c_n) is exactly such a sequence.

• The number of ways to color nn distinguishable objects using kk colors with reuse allowed.

Examples:

• Assigning 44 distinct tasks to 33 workers (any worker may get any number of tasks): 34=813^4 = 81 assignments.

• Sending 55 different letters to 33 different mailboxes: 35=2433^5 = 243 sendings.

• Coloring 66 distinct beads with 44 colors, repeats allowed: 46=40964^6 = 4096 colorings.

• Number of functions from a 33-element set to a 55-element set: 53=1255^3 = 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 nn items independently picks one of kk cells:

Item 1: kk choices.

Item 2: kk choices (independent of item 1).

Item 3: kk choices.

\dots

Item $n$: kk choices.

Multiply nn identical factors of kk:

k×k×k××k=knk \times k \times k \times \dots \times k = k^n


The tool visualizes the equivalent decomposition: fix where item 1 goes (kk ways), then ask how many ways the remaining n1n - 1 items can be distributed independently (kn1k^{n - 1} ways). Every row in the completed section is one of those kk 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 nn instead would give the same decomposition into kk equal-size groups, just labeled differently. This is the visual signature of full independence.

Counts grow quickly: 25=322^5 = 32, 35=2433^5 = 243, 55=31255^5 = 3125. The base kk and exponent nn play asymmetric roles — increasing nn multiplies the count by kk, increasing kk multiplies by a factor that itself depends on nn.

Related Concepts

Permutation with repetition — the same formula nrn^r, but with the roles of nn and rr swapped semantically. There, rr positions independently pick from nn options; here, nn items independently pick from kk cells. Mathematically identical: rr positions ↔ nn items, nn options ↔ kk cells.

Weak composition — distributes nn identical items into kk labeled cells, with empties allowed. Formula (n+k1k1)\binom{n + k - 1}{k - 1}. Strictly smaller than knk^n because the items can no longer be told apart.

Strong composition — like weak composition but every cell must receive at least one item. Formula (n1k1)\binom{n - 1}{k - 1}.

Partition into groups — distributes nn distinct items into kk labeled cells of fixed sizes. Adds a hard constraint that turns knk^n into the multinomial coefficient.

Functions from a set to a set — the algebraic reading. Counting functions f:ABf: A \to B with A=n|A| = n and B=k|B| = k gives knk^n, sometimes written BAB^A.

Surjective functions — functions where every cell is hit. Counted by k!S(n,k)k! \cdot S(n, k) where S(n,k)S(n, k) is the Stirling number of the second kind. Always at most knk^n.

Pigeonhole principle — when n>kn > k, at least one cell must contain more than one item. The distribution count knk^n includes every such forced overlap.

Combinatorics calculator — to compute knk^n for arbitrary nn and kk, see the distribution into cells calculator.