MatheramaMatherama
← Combinatorics
Combinatorics·Section 6·13 min read

Permutations with Repetition and Multisets

In Sections 03 and 05, every object was distinct from every other object. In real counting problems, however, identical copies of objects often appear—such as repeated letters in a word, identical coins in a pocket, or digits reused in an access code.

When some objects are indistinguishable, swapping two identical objects does not create a new arrangement, so the total number of distinct permutations shrinks. In this section we study three regimes of permutations with repetition:

  1. Full permutations when each object repeats a fixed number of times (multisets).
  2. Partial (rr-) permutations of a finite multiset.
  3. Permutations when repetition is allowed any number of times (unlimited supply).

Permutations of a Multiset (Fixed Multiplicities)§

Start with a small example: how many distinct permutations of the letters a,a,ba, a, b exist?

Listing all possibilities gives only three arrangements:

aab,aba,baaaab, \qquad aba, \qquad baa

If all three letters had been distinct (a1,a2,ba_1, a_2, b), there would have been 3!=63! = 6 permutations. Because the two aa's are identical, interchanging them produces no new word, cutting the count in half.

Now consider a larger word: MISSISSIPPI. It has 1111 letters, with several repetitions. To record both the distinct types of objects and how many times each occurs, we write a multiset:

A={1⋅M,  4⋅I,  4⋅S,  2⋅P}A = \{1 \cdot \text{M},\; 4 \cdot \text{I},\; 4 \cdot \text{S},\; 2 \cdot \text{P}\}

To count all distinct 1111-letter arrangements of MISSISSIPPI, picture 1111 distinct numbered slots in a row and place one letter type at a time:

  1. Place the 11 M: Choose 11 of the 1111 slots in (111)\binom{11}{1} ways. Now 1010 slots remain.
  2. Place the 44 identical I's: Choose 44 of the remaining 1010 slots in (104)\binom{10}{4} ways. Notice that we use combinations (not permutations) because all four I's are identical—rearranging them among their 44 chosen slots produces the exact same word. Now 66 slots remain.
  3. Place the 44 identical S's: Choose 44 of the remaining 66 slots in (64)\binom{6}{4} ways. Now 22 slots remain.
  4. Place the 22 identical P's: Fill the final 22 slots in (22)=1\binom{2}{2} = 1 way.

By the Multiplication Principle, the intermediate factorials cancel cleanly:

(111)×(104)×(64)×(22)=11!1! 10!×10!4! 6!×6!4! 2!×2!2! 0!=11!1! 4! 4! 2!=34,650\binom{11}{1} \times \binom{10}{4} \times \binom{6}{4} \times \binom{2}{2} = \frac{11!}{1!\,10!} \times \frac{10!}{4!\,6!} \times \frac{6!}{4!\,2!} \times \frac{2!}{2!\,0!} = \frac{11!}{1!\,4!\,4!\,2!} = 34{,}650

Building a Permutation of MISSISSIPPI by Sequentially Choosing Slots

The General Multiset Permutation Theorem§

Theorem (Multiset Permutations): Let A={n1⋅a1,  n2⋅a2,  …,  nk⋅ak}A = \{n_1 \cdot a_1,\; n_2 \cdot a_2,\; \dots,\; n_k \cdot a_k\} be a multiset containing kk distinct types of objects repeated n1,n2,…,nkn_1, n_2, \dots, n_k times respectively, and let n=n1+n2+⋯+nkn = n_1 + n_2 + \dots + n_k be the total number of objects. The total number of distinct linear permutations of all nn objects is:

n!n1! n2! n3! ⋯ nk!\frac{n!}{n_1!\, n_2!\, n_3!\, \cdots \, n_k!}

Proof 1 (Sequential Slot Selection): Choose n1n_1 of the nn slots for the copies of a1a_1 in (nn1)\binom{n}{n_1} ways, then n2n_2 of the remaining n−n1n - n_1 slots for a2a_2 in (n−n1n2)\binom{n - n_1}{n_2} ways, and continue until the last nkn_k copies of aka_k fill the remaining nkn_k slots in (nknk)\binom{n_k}{n_k} ways. Multiplying and canceling consecutive factorials gives:

(nn1)(n−n1n2)⋯(nknk)=n!n1!(n−n1)!⋅(n−n1)!n2!(n−n1−n2)!⋯nk!nk! 0!=n!n1! n2! ⋯ nk!■\binom{n}{n_1}\binom{n - n_1}{n_2}\cdots\binom{n_k}{n_k} = \frac{n!}{n_1!(n - n_1)!} \cdot \frac{(n - n_1)!}{n_2!(n - n_1 - n_2)!} \cdots \frac{n_k!}{n_k!\,0!} = \frac{n!}{n_1!\,n_2!\,\cdots\,n_k!} \qquad \blacksquare

Proof 2 (Via the Division Principle): Temporarily attach distinct subscript labels to identical objects so all nn objects become distinguishable. These nn labeled objects permute in n!n! ways. Removing the temporary labels groups every distinct multiset permutation into an equivalence class of equal size n1!n2!⋯nk!n_1! n_2! \cdots n_k! (the number of ways to permute identical copies among themselves). By the Division Principle, dividing n!n! by n1!n2!⋯nk!n_1! n_2! \cdots n_k! yields the exact count. ■\blacksquare

Example 1 (Bundle Method with Identical Objects): In how many ways can the letters of ASSASSINATION be arranged so that all the S's stay together?

Solution: The word has 1313 letters: {3⋅A,  4⋅S,  2⋅I,  2⋅N,  1⋅T,  1⋅O}\{3 \cdot \text{A},\; 4 \cdot \text{S},\; 2 \cdot \text{I},\; 2 \cdot \text{N},\; 1 \cdot \text{T},\; 1 \cdot \text{O}\}.

Tie all 44 S's into a single block [SSSS]. Because all four S's are identical, there is only 11 internal arrangement inside the block (not 4!4!). We now permute 13−4+1=1013 - 4 + 1 = 10 objects with multiplicities 33 A's, 22 I's, 22 N's, 11 T, 11 O, and 11 [SSSS]:

10!3! 2! 2! 1! 1! 1!=3,628,80024=151,200\frac{10!}{3!\,2!\,2!\,1!\,1!\,1!} = \frac{3{,}628{,}800}{24} = 151{,}200

Example 2 (Gap Method with Identical Objects): Find the number of arrangements of MISSISSIPPI in which no two I's are adjacent.

Solution: First arrange the 77 non-I letters (M, 44 S's, 22 P's):

7!1! 4! 2!=105\frac{7!}{1!\,4!\,2!} = 105

These 77 letters create 88 gaps (including both outer ends). We must place the 44 I's into 44 of these 88 gaps. Be careful: because all 44 I's are identical, we choose 44 gaps using (84)\binom{8}{4}—not 8P4{}^8 P_4!

Total arrangements=105×(84)=105×70=7350\text{Total arrangements} = 105 \times \binom{8}{4} = 105 \times 70 = 7350

Example 3 (Fixed Relative Order): In how many ways can the letters of MATHEMATICS be arranged such that the vowels (A, E, A, I) always appear in alphabetical order (A, A, E, I) from left to right (not necessarily adjacent)?

Solution: MATHEMATICS has 1111 letters: {2⋅M,  2⋅A,  2⋅T,  1⋅H,  1⋅E,  1⋅I,  1⋅C,  1⋅S}\{2 \cdot \text{M},\; 2 \cdot \text{A},\; 2 \cdot \text{T},\; 1 \cdot \text{H},\; 1 \cdot \text{E},\; 1 \cdot \text{I},\; 1 \cdot \text{C},\; 1 \cdot \text{S}\}.

Here is a slick trick using the multiset formula: temporarily treat all 44 vowels (A, A, E, I) as 44 identical blank tokens □, □, □, □! Arrange the 1111 symbols (44 □'s, 22 M's, 22 T's, H, C, S) in:

11!4! 2! 2!=415,800 ways\frac{11!}{4!\,2!\,2!} = 415{,}800 \text{ ways}

In every such arrangement, there is only 11 way to replace the four □ slots from left to right with A, A, E, I in alphabetical order! Hence the answer is 415,800415{,}800.


Dictionary Rank of a Word with Repeated Letters§

In Section 03, we computed the dictionary rank of words whose letters are all distinct. Now that we have the Multiset Permutation Formula, we can extend that exact prefix-by-prefix algorithm to words with repeated letters.

At each position ii from left to right, count how many words start with a smaller unused letter at position ii. Whenever a remaining suffix has repeated letters with multiplicities m1,m2,…m_1, m_2, \dots, the number of distinct suffix permutations is (n−i)!m1! m2!⋯\frac{(n - i)!}{m_1!\,m_2!\cdots}. Equivalently, you may count all unused letters strictly before the ii-th letter (with multiplicity) and divide by the factorials of the multiplicities of all remaining letters (including the current letter itself).

Example 4 (Repeated Letters — SMALL): Find the dictionary rank of the word SMALL.

Solution: Sort the 55 letters alphabetically: A, L, L, M, S.

  • Position 1 (S): Remaining multiset is {A, L, L, M, S} (L repeated twice). There are 44 letters strictly before S (A, L, L, M), giving 4×4!2!=48\frac{4 \times 4!}{2!} = 48 preceding words. (Check directly: starting with A gives 4!2!=12\frac{4!}{2!} = 12; starting with L gives 4!=244! = 24; starting with M gives 4!2!=12\frac{4!}{2!} = 12; and 12+24+12=4812 + 24 + 12 = 48.) Lock S.
  • Position 2 (M): Remaining {A, L, L, M} (L repeated twice). Three letters precede M (A, L, L), giving 3×3!2!=9\frac{3 \times 3!}{2!} = 9 words. Lock M.
  • Position 3 (A): Remaining {A, L, L}; 00 letters precede A   ⟹  0\implies 0. Lock A.
  • Position 4 (L): Remaining {L, L}; 00 letters precede L   ⟹  0\implies 0. Lock L.
  • Position 5 (L): 00.

Adding 11 for SMALL itself:

Rank(SMALL)=48+9+0+0+0+1=58\text{Rank}(\text{SMALL}) = 48 + 9 + 0 + 0 + 0 + 1 = 58

Example 5 (Multiple Repeated Letters — BANANA): Find the dictionary rank of the word BANANA.

Solution: Sort the 66 letters alphabetically: A, A, A, B, N, N.

  • Position 1 (B): Remaining {A, A, A, B, N, N} (33 A's, 22 N's). Only A precedes B (33 copies), giving 3×5!3! 2!=30\frac{3 \times 5!}{3!\,2!} = 30 words (starting with A, the remaining {A, A, B, N, N} permute in 5!2! 2!=30\frac{5!}{2!\,2!} = 30 ways). Lock B.
  • Position 2 (A): Remaining {A, A, A, N, N}; 00 letters precede A   ⟹  0\implies 0. Lock A.
  • Position 3 (N): Remaining {A, A, N, N} (22 A's, 22 N's). Two A's precede N, giving 2×3!2! 2!=3\frac{2 \times 3!}{2!\,2!} = 3 words. Lock N.
  • Position 4 (A): Remaining {A, A, N}; 00 letters precede A   ⟹  0\implies 0. Lock A.
  • Position 5 (N): Remaining {A, N}. One A precedes N, giving 1×1!=11 \times 1! = 1 word (BANANA is preceded by BANAAN). Lock N.
  • Position 6 (A): 00.

Adding 11 for BANANA itself:

Rank(BANANA)=30+0+3+0+1+0+1=35\text{Rank}(\text{BANANA}) = 30 + 0 + 3 + 0 + 1 + 0 + 1 = 35

Partial Permutations of Non-Distinct Objects§

What if we do not use all letters of a multiset, and instead ask for the number of rr-permutations (say, 44-letter words) formed from a multiset like MISSISSIPPI?

Here there is no single elementary closed-form formula, because different letters have different supply limits. (In a later chapter, Exponential Generating Functions provide a general algebraic engine for this problem.) With our current tools, the clean, rigorous method is to partition all rr-letter words into mutually exclusive, exhaustive cases based on how many distinct letters appear and how often they repeat, then add the cases.

Example 6 (Four-Letter Words from MISSISSIPPI): How many distinct 44-letter words can be formed using the letters of MISSISSIPPI?

Solution: Our available multiset is {1⋅M,  4⋅I,  4⋅S,  2⋅P}\{1 \cdot \text{M},\; 4 \cdot \text{I},\; 4 \cdot \text{S},\; 2 \cdot \text{P}\} (44 distinct letter types). Partition all 44-letter words by the number of distinct letters they contain:

Case I (All 44 letters distinct — pattern 1+1+1+11 + 1 + 1 + 1): There are only 44 distinct letter types in total (M, I, S, P), so we must use one of each. They permute in:

4!=24 words4! = 24 \text{ words}

Case II (Exactly 33 distinct letters — pattern 2+1+12 + 1 + 1): One letter must appear twice, and two other letters once each.

  • Only I, S, and P have at least 22 copies, so choose the repeating letter in (31)=3\binom{3}{1} = 3 ways.
  • Choose 22 other distinct letters from the remaining 33 letter types in (32)=3\binom{3}{2} = 3 ways.
  • Arrange the 44 selected letters (one repeated twice) in 4!2! 1! 1!=12\frac{4!}{2!\,1!\,1!} = 12 ways.

Total words in Case II:

(31)×(32)×4!2!=3×3×12=108\binom{3}{1} \times \binom{3}{2} \times \frac{4!}{2!} = 3 \times 3 \times 12 = 108

Case III (Exactly 22 distinct letters): Two letters forming a 44-letter word can repeat in two disjoint ways—either both appear twice (2+22 + 2), or one appears three times and the other once (3+13 + 1).

  • Subcase IIIa (Pattern 2+22 + 2): M cannot be used (only 11 copy available). Choose 22 letter types from {I, S, P} in (32)=3\binom{3}{2} = 3 ways, and arrange them in 4!2! 2!=6\frac{4!}{2!\,2!} = 6 ways:
(32)×4!2! 2!=3×6=18\binom{3}{2} \times \frac{4!}{2!\,2!} = 3 \times 6 = 18
  • Subcase IIIb (Pattern 3+13 + 1): Only I and S have at least 33 copies. Choose the triply repeated letter in (21)=2\binom{2}{1} = 2 ways, choose 11 other distinct letter from the remaining 33 types in (31)=3\binom{3}{1} = 3 ways, and arrange in 4!3! 1!=4\frac{4!}{3!\,1!} = 4 ways:
(21)×(31)×4!3!=2×3×4=24\binom{2}{1} \times \binom{3}{1} \times \frac{4!}{3!} = 2 \times 3 \times 4 = 24

Total words in Case III =18+24=42= 18 + 24 = 42.

Case IV (Only 11 distinct letter — pattern 44): The single letter must repeat 44 times. Only I and S have 44 copies, giving (21)×4!4!=2\binom{2}{1} \times \frac{4!}{4!} = 2 words (IIII and SSSS).

By the Addition Principle, summing all four disjoint, exhaustive cases:

Total 4-letter words=24+108+42+2=176\text{Total 4-letter words} = 24 + 108 + 42 + 2 = 176

Example 7 (Four-Letter Words from EXAMINATION): How many distinct 44-letter words can be formed using the letters of EXAMINATION?

Solution: The multiset is {2⋅A,  2⋅I,  2⋅N,  1⋅E,  1⋅X,  1⋅M,  1⋅T,  1⋅O}\{2 \cdot \text{A},\; 2 \cdot \text{I},\; 2 \cdot \text{N},\; 1 \cdot \text{E},\; 1 \cdot \text{X},\; 1 \cdot \text{M},\; 1 \cdot \text{T},\; 1 \cdot \text{O}\}. There are 88 distinct letter types; 33 types (A, I, N) appear twice, and no letter appears 33 or more times. Thus only three patterns are possible:

  • Pattern 1+1+1+11 + 1 + 1 + 1: (84)×4!=70×24=1680\binom{8}{4} \times 4! = 70 \times 24 = 1680.
  • Pattern 2+1+12 + 1 + 1: (31)×(72)×4!2!=3×21×12=756\binom{3}{1} \times \binom{7}{2} \times \frac{4!}{2!} = 3 \times 21 \times 12 = 756.
  • Pattern 2+22 + 2: (32)×4!2! 2!=3×6=18\binom{3}{2} \times \frac{4!}{2!\,2!} = 3 \times 6 = 18.

Total 44-letter words =1680+756+18=2454= 1680 + 756 + 18 = 2454.


Permutations with Unlimited Repetition§

In many situations, copies of every distinct object are available in unlimited (infinite) supply. We denote such a multiset by:

A={∞⋅a1,  ∞⋅a2,  ∞⋅a3,  …,  ∞⋅an}A = \{\infty \cdot a_1,\; \infty \cdot a_2,\; \infty \cdot a_3,\; \dots,\; \infty \cdot a_n\}

Suppose we arrange objects from AA into kk distinct fixed places. Because each type can be reused freely, the first place can be filled in nn ways, the second place in nn ways, ..., and the kk-th place in nn ways independently.

Theorem (Permutations with Unlimited Repetition): The number of kk-permutations of nn distinct types of objects when each type may be repeated any number of times is:

n×n×n×⋯×n⏟k times=nk\underbrace{n \times n \times n \times \dots \times n}_{k \text{ times}} = n^k

Example 8: How many 55-digit numbers can be formed using the digits {0,1,2,3,4,5}\{0, 1, 2, 3, 4, 5\} if repetition of digits is allowed and the number must be divisible by 55?

Solution:

  • Ten-thousands place: 55 choices (1,2,3,4,51, 2, 3, 4, 5; cannot be 00).
  • Thousands, hundreds, and tens places: 66 choices each (all digits allowed with repetition).
  • Units place: 22 choices (00 or 55, for divisibility by 55).

By the Multiplication Principle, there are 5×63×2=21605 \times 6^3 \times 2 = 2160 such numbers.

Example 9 (Ship Signals): A ship carries an unlimited supply of red, blue, and green signal flags. How many distinct vertical signals can be hoisted using at least 11 and at most 44 flags?

Solution: Partition by the exact number of flags hoisted (k=1,2,3,4k = 1, 2, 3, 4). A vertical signal of kk flags can be formed in 3k3^k ways. By the Addition Principle:

31+32+33+34=3+9+27+81=1203^1 + 3^2 + 3^3 + 3^4 = 3 + 9 + 27 + 81 = 120

Summary Table§

Problem Type Formula / Method Key Detail
Full permutation of multiset {n1⋅a1,…,nk⋅ak}\{n_1 \cdot a_1, \dots, n_k \cdot a_k\} n!n1! n2! ⋯ nk!\frac{n!}{n_1!\,n_2!\,\cdots\,n_k!} (n=∑nin = \sum n_i) Divide n!n! by the factorial of each multiplicity
rr-permutation of finite multiset Partition by frequency patterns of rr Select letter types per pattern, then arrange via multiset formula
kk-permutation with unlimited repetition nkn^k Each of kk positions has nn independent choices
No two identical objects adjacent Arrange remaining objects, then choose gaps with (gm)\binom{g}{m} Use (gm)\binom{g}{m}, not gPm{}^g P_m, because identical copies are indistinguishable
Fixed relative order among mm objects Replace those mm objects by mm identical tokens □ Only 11 way to fill the □ slots in the required order
Section 6 of 11 · Combinatorics

Mark this section complete when you have worked through its proofs.