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.
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.
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.
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.
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 coefficient n!/(k1!⋅k2!⋯).
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).
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!
Related Concepts
Full permutation — the case where every item is distinct, so all ki=1. The formula reduces to n! because every factorial in the denominator is 1.
Partial permutation without repetition — pick and arrange only r items from a distinct set of n. Formula n!/(n−r)!.
Permutation with repetition — items can be reused, but a fixed pool of n distinct options is used for r positions. Formula nr.
Circular permutation — arrange items around a circle where rotations are identical. Formula (n−1)!.
Multinomial coefficient — the direct algebraic name for n!/(k1!⋅k2!⋯). Generalizes the binomial coefficient and appears in the multinomial theorem.
Binomial coefficient — the special case with exactly two groups: (kn)=n!/(k!⋅(n−k)!). Counts arrangements of a multiset with two distinct items.
Combinatorics calculator — to compute n!/(k1!⋅k2!⋯) for any multiset, see the multiset permutation calculator.