Press ▶ Play to build all n! / (k₁!·k₂!·…) distinct arrangements of the chosen multiset, or Step ▶ to advance one ball at a time. Cycle the multiset to try different duplicate patterns.
● BallsA Letters
multiset =AAB?
Speed
Permutations with identical items
3! / (2! · 1!) = 3
Arrange a multiset of n items where some are identical. Swapping two copies of the same item doesn't produce a new arrangement, so we divide the total n! by k! for each group of identical copies.
The multiset waits in the source row — duplicates drawn side by side, slots empty below. The count is already fixed by the letter multiplicities. Learn more about getting started · All multisets
Multiset — a collection of items where some may be identical. Unlike a set, a multiset records how many copies of each item are present. In this tool the multiset is encoded as a string like *AABBC*.
Permutation with identical items — a distinct arrangement of a multiset in a line. Swapping two identical copies does not produce a new permutation. The count is n!/(k1!⋅k2!⋯) where each ki is the size of an identical group.
Multinomial coefficient — the formula (k1,k2,…n)=n!/(k1!⋅k2!⋯). The generalization of the binomial coefficient to more than two groups.
Distinct first item — a unique item value in the multiset. The completed section groups arrangements by which distinct item appears in position #1, so there is one group per distinct item, not one per source position.
Positional dimming — the source row shows every copy in its own position. When a copy is used in the current build, only that position dims — the other copies of the same item stay fully visible.
Group size — the number of distinct arrangements in a first-item group. With ki copies of the chosen first item, that count is (n−1)!/((ki−1)!⋅∏j=ikj!), which varies between groups.
Getting Started
The tool opens with multiset *AAB* selected: two copies of A and one copy of B. The scene splits into three areas:
• A source row at the top showing the multiset as separate balls, including duplicates side by side.
• A build area in the middle with n slots, where n is the total size of the multiset (counting duplicates).
• A completed section below, where every finished distinct permutation is filed under the row matching its first item.
To run the visualization:
• Press ▶ Play to auto-build all distinct permutations of the current multiset.
• Press Step ▶ to advance one ball at a time.
• Press ◀ to step backward through the animation.
• Adjust the Speed slider to control how fast play advances.
The header shows the formula n!/(k1!⋅k2!⋯)=total together with a live status line like *Group A: k / size* while building.
AAB, idle, frozen
Two red A balls, one blue B, three dashed slots: the smallest multiset, waiting. The copies are drawn apart but will be counted as one.
The frozen frame above is the opening position for the default multiset: two red A balls side by side, one blue B, three dashed slots. Already the central subtlety is on display — the two A balls are drawn as separate objects even though, mathematically, they are the same letter.
That tension is the whole subject. The tool draws copies separately so you can watch them move, then counts as if they were indistinguishable — the reconciliation is the division explained under why divide by k!.
The Build Area
The build area is where one distinct permutation at a time is constructed. The label above the area simply reads *BUILD AREA*; the slot count equals the size of the chosen multiset.
What to watch:
• Empty slot outlines with dashed borders, labeled #1,#2,…,#n from left to right.
• When a ball is in flight from the source row to a slot, a dotted guide line traces the trajectory in the color of the item being moved.
• Each ball lands in its assigned slot and stays put until the permutation completes.
• In the source row, only the specific copy being used dims — not every copy of that item. So when one of the two A balls flies into a slot, the other A stays bright. This is the visual signature of positional dimming.
• When all n slots are filled, a flash ring briefly pulses around the build area, and the completed arrangement is filed in the appropriate first-item row below.
AAB mid-build, frozen
A has landed in slot #1 and its own source copy dims — but its identical twin stays bright. B rides the dotted guide toward slot #2.
The frozen frame above shows positional dimming doing its job: A has landed in slot #1 and its source copy is dimmed, B is mid-flight along its dotted guide — but the second A is still bright, because that particular copy has not been used.
Positional dimming is the honest way to animate a multiset: the tool must move one specific ball, even though the mathematics does not care which A it was. Every arrangement the build produces would look identical if the two A copies swapped roles — exactly the redundancy the formula divides away.
The Multiset Stepper
Instead of an n stepper, this tool has a multiset stepper that cycles through six curated presets, increasing in complexity:
• AAB — two of A, one of B. 3!/(2!⋅1!)=3 distinct permutations.
• AAAB — three of A, one of B. 4!/(3!⋅1!)=4 permutations.
• AABB — two each of A and B. 4!/(2!⋅2!)=6 permutations.
• AABC — two of A, one each of B and C. 4!/(2!⋅1!⋅1!)=12 permutations.
• AAABB — three of A, two of B. 5!/(3!⋅2!)=10 permutations.
• AABBC — two each of A and B, one of C. 5!/(2!⋅2!⋅1!)=30 permutations.
Use the ◀ and ▶ buttons next to *multiset =* to cycle. Each preset resets the build, refreshes the formula in the header, and rebuilds the completed section into the new set of first-item rows.
AAB: The Smallest Multiset
The opening preset is the smallest multiset with a genuine duplicate: two copies of A and one B. Its three distinct arrangements can be written out faster than any formula: AAB, ABA, BAA.
The formula agrees: 3!/(2!⋅1!)=6/2=3. Without the division, the six tagged permutations of A1A2B would each be counted — but A1A2B and A2A1B are the same word once the tags come off.
Three is also the count of *positions the single B can occupy* — last, middle, or first. With only one non-duplicate letter, the whole arrangement is determined by where that letter sits.
AAB complete, frozen
Three cards in two unequal rows: AAB and ABA under the A group, BAA alone under B — 3!/2! = 3, checkable by hand.
The frozen run above shows the tool's two unequal groups: the A-first row holds AAB and ABA, the B-first row holds only BAA. Starting with the duplicate leaves a mixed pair to arrange two ways; starting with B leaves the identical pair AA, which can be "arranged" in exactly one.
Being fully enumerable by hand makes this the preset to verify against. Every claim on this page — the group sizes, the positional dimming, the division — can be checked here in seconds before the larger presets put it beyond patience.
AAAB: Placing the Single B
Three copies of A and a single B: 4!/(3!⋅1!)=4 distinct arrangements — AAAB, AABA, ABAA, BAAA.
The count equals the number of slots the lone B can occupy, and that is no coincidence: when a multiset has just one letter that differs, an arrangement carries no information beyond *where the odd one out went*. Four positions, four arrangements.
Watch the group structure: the A-first row holds three arrangements (the B still has three slots left to choose from), while the B-first row holds exactly one — BAAA, with all decisions already made.
AAAB complete, frozen
Four arrangements, one per possible home of the single B. The A-first row holds three; the B-first row is a row of one.
This preset is the cleanest bridge to combinations: "choose which 1 of the 4 positions holds B" is (14)=4. The multinomial 4!/(3!⋅1!) and the binomial (14) are the same number wearing different notation — a coincidence that becomes a theorem in the two-letter preset AAABB.
Try predicting before pressing Play: which group will fill first, and how large will each be? The frozen frame above is the answer key.
AAABB: Two Letters, Ten Arrangements
Three As and two Bs give 5!/(3!⋅2!)=120/12=10 distinct arrangements — the largest two-letter preset in the stepper.
Ten should ring a bell: (25)=10 as well. With exactly two distinct letters, arranging the multiset is the same act as *choosing which positions get the* B*s* — order inside each letter group is meaningless, so only the choice of positions matters. Every two-letter multiset permutation is secretly a binomial coefficient:
k!⋅(n−k)!n!=(kn)
The group split is 6+4: starting with A leaves AABB (six ways), starting with B leaves AAAB (four ways) — both remainders being smaller presets from this very stepper.
AAABB complete, frozen
Ten arrangements of three A and two B — the same ten that C(5,2) counts, since only the B positions carry information.
The recursion visible in the group sizes is worth savoring: the A-first row is exactly the AABB preset shifted one slot right, and the B-first row is the AAAB preset. Multiset permutations decompose into smaller multiset permutations, just as n! decomposed into first-item families for distinct items.
This preset is also the page's binomial ambassador: any time you compute (kn), you are counting the arrangements of a two-letter multiset with k of one letter and n−k of the other.
AABBC: The Longest Run
The final preset has five items in three groups — two As, two Bs, one C — and produces the stepper's largest count: 5!/(2!⋅2!⋅1!)=120/4=30 distinct arrangements.
Thirty is small enough to enumerate on screen but large enough that the structure, not the list, is what you remember. The three first-item rows hold 12+12+6 arrangements: starting with A or B leaves one duplicate pair intact (ABBC or AABC-type remainders, twelve ways each), while starting with C leaves both pairs AABB — the most collapsible remainder, six ways.
The denominator 2!⋅2!⋅1!=4 means each card on screen quietly stands for four tagged permutations of the 120 total.
AABBC complete, frozen
The longest run: thirty cards in rows of 12, 12, and 6, each card silently standing for four of the 120 tagged permutations.
A full Play run of this preset is the page's best show: thirty completions, three rows filling at different rates, and the counter climbing to the multinomial total. If the smaller presets proved the formula, this one demonstrates its economy — nobody wants to hand-list thirty words to learn what 120/4 already says.
For genuinely large multisets the tool bows out and the formula alone remains: MISSISSIPPI's 34,650 arrangements, computed under what is a permutation with identical items, would need a screen four hundred times taller.
Grouping by Distinct First Item
The completed section organizes permutations into distinct first-item groups — one row per distinct value in the multiset, not one per source position. So *AAB* has two groups (A and B), not three.
Group sizes vary because the remaining multiset depends on which item was used first. For example with *AABB*:
• Starting with A: remaining multiset is ABB, giving 3!/(1!⋅2!)=3 arrangements.
• Starting with B: remaining multiset is AAB, also giving 3!/(2!⋅1!)=3 arrangements.
For *AABC*:
• Starting with A: remaining is ABC (no repeats), giving 3!=6 arrangements.
• Starting with B: remaining is AAC, giving 3!/2!=3.
• Starting with C: remaining is AAB, giving 3!/2!=3.
This is why each row in the completed area has its own height — the tool computes a separate row size per group to keep proportions clean. The total across all groups always equals the multinomial coefficientn!/(k1!⋅k2!⋯).
AABC complete, frozen
Twelve cards in unequal rows of 6, 3, and 3: starting with the duplicate A frees the remainder; starting with B or C leaves the pair AA to collapse.
The frozen frame above is *AABC* complete, and the unequal rows tell the story at a glance: the A row holds six cards while the B and C rows hold three each. Starting with A uses up one of the duplicates and leaves three distinct letters — the freest possible remainder — while starting with B or C leaves the pair AA intact to keep collapsing arrangements.
Unequal group sizes are the feature that separates this tool from the full permutation's perfectly even rows: with duplicates, symmetry among first choices is broken by what each choice leaves behind. Adding down the rows — 6+3+3=12 — recovers the multinomial total.
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 arrangement or pausing mid-build.
• Step ▶ (Step forward) — advances one ball into one slot. Stop after each step to read the partial arrangement.
• ▶ Play / ⏸ Pause — runs the animation continuously until all distinct permutations are built, then auto-pauses.
• ↺ Reset — clears the completed section and starts over from the first arrangement.
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 its source position to the assigned slot.
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. Identical copies share the same color, so the multiset *AABB* shows two circles of one color and two of another. The first-item avatar in each completed group is a circle with the item's number.
• Letters mode — items appear with letter labels (A, B, C, …). The multiset display becomes literal — *AABB* shows as A,A,B,B in the source row. The first-item avatar in each completed group is just the letter, colored to match.
The encoding is consistent across the source row, the build slots, the flying ball, every mini permutation card in the completed grid, and the right-panel narration. Letters mode is especially useful for this scenario because the multiset names themselves are letter strings.
Right Panel and Progress
The right panel narrates the build as it unfolds, anchored by the header *Permutations with identical items* and the full multinomial formula for the current multiset.
A StepRow is added for each distinct first-item group as soon as a permutation in that group starts or completes. Each StepRow shows:
• The first item as a chip plus its name — for instance, *First item: A*.
• A progress counter like k/group size tracking how many distinct permutations in this group have completed.
• A short narration of the structure: *Position 1 is locked to A. The remaining positions hold 1 A, 2 Bs, and 1 C, arranged in 4!/(1!⋅2!⋅1!)=12 distinct ways.* The formula uses the leftover multiplicities after one copy of the first item is removed.
When all groups complete, every StepRow shows *done* with a checkmark, and the counter reaches *total / total*.
What Is a Permutation with Identical Items
A permutation with identical items is a distinct arrangement of a multiset — a collection of n items where some are repeated. Two arrangements count as the same if they only differ by swapping copies of the same item. The number of distinct arrangements is:
k1!⋅k2!⋯km!n!
where ki is the number of copies of the ith distinct item and k1+k2+⋯+km=n. This is the multinomial coefficient(k1,k2,…,kmn), and the reason for the division is worked out under why divide by k!.
Examples:
• Distinct arrangements of the letters in *MISSISSIPPI* (11 letters: 1 M, 4 I, 4 S, 2 P): 11!/(1!⋅4!⋅4!⋅2!)=34,650.
• Distinct arrangements of the word *DATA* (4 letters with 2 A): 4!/2!=12.
• Lining up 8 students where 3 wear identical red shirts and 5 wear identical blue shirts: 8!/(3!⋅5!)=56 distinguishable lineups.
For deeper coverage, see the permutation with identical items section on the permutations theory page.
Why Divide by k!
Start with the multiset treated as if every item were distinct — say by tagging copies A1,A2 and B1,B2 for *AABB*. There are n!=4!=24 full permutations of the tagged set.
But the tags are fake. When we remove them and look at the actual multiset, many of those 24 permutations collapse into the same arrangement:
• The two A copies can swap in 2!=2 ways without changing what we see.
• The two B copies can swap in 2!=2 ways without changing what we see.
• Together, 2!⋅2!=4 tagged permutations map to each distinct untagged arrangement.
So the distinct count is 24/4=6, matching the formula 4!/(2!⋅2!).
Generalizing: for each identical group of size ki, exactly ki! tagged permutations collapse into one untagged arrangement. Dividing n! by the product of all such ki! removes every layer of redundancy:
distinct count=k1!⋅k2!⋯km!n!
AABB complete, frozen
Six cards, three per row — each standing for 2!·2! = 4 invisible swaps of tagged copies. 24 tagged permutations, 6 visible words.
The frozen frame above is the argument's own example completed on screen: *AABB*, six cards, split three-and-three between the A-first and B-first rows. Each visible card stands for exactly four invisible tagged permutations — the 2!⋅2! silent swaps of the copies.
The collapse ratio is the same for every card, which is why plain division works: redundancy in this problem is perfectly uniform. Run the build and watch for repeats that never come — the enumeration simply skips arrangements it has already produced, which is division enacted rather than computed. The remaining presets scale the same idea; see the multiset stepper for the full ladder.