How to use the multiset permutation calculator
- Type a word or a list of items. Choose whether each character is an item or the items are separated by commas.
- Pick what to find: the number of distinct arrangements, the rank of one arrangement, or the arrangement at a given rank.
- For the count, leave length blank to arrange every item, or enter a smaller number to choose that many items.
- Read the answer, the table of items and the first arrangements in dictionary order.
Formula
Arrangements of all n items = n! / (n1! x n2! x ... x nk!)
Rank of an arrangement = sum over each place of the arrangements that begin with a smaller unused item
Arrangement at a rank: at each place take the smallest item whose block of arrangements contains the rank
Arrangements of length r: add one kind of item at a time, choosing C(l, j) places for its j copies
n! is the number of orders of n different items, and each n_i! removes the orders of identical items that look the same. Ranks use dictionary order by character code.
MISSISSIPPI and BANANA
MISSISSIPPI has 11 letters: I four times, M once, P twice and S four times. The number of distinct arrangements is 11! / (4! x 1! x 2! x 4!) = 39,916,800 / 1,152 = 34,650. If all 11 letters were different there would be 39,916,800. Choosing arrangements of only 4 letters gives 176.
BANANA has 60 arrangements. The first in dictionary order is AAABNN and the last is NNBAAA. NABANA is preceded by 47 arrangements, so it has rank 48 of 60, and the arrangement at rank 38 is BNAANA.
Why repeated items change the count
With n different items there are n! orders. When some items are identical, swapping two of them gives a sequence that looks the same, so the same arrangement was counted several times. Dividing by the factorial of each group size removes exactly those duplicates. This is the rule behind counting anagrams, color patterns of beads and sequences of repeated moves.
It is a special case of a multinomial coefficient. For choosing a subset without caring about order, see the combinations and permutations calculator. For partitions into groups of unlabeled items, see the Stirling and Bell numbers page.
Ranking and unranking
Dictionary order lists the arrangements the way a dictionary would list words. Ranking tells you where one arrangement falls in that list without writing the list out, and unranking goes the other way. Both work place by place using counts, so they stay fast even when the full list would have billions of entries, which is why the results are shown in full with digit grouping.
Uppercase and lowercase letters are different items. In the order used here, every uppercase letter comes before every lowercase letter, because items are compared by character code.
Assumptions and limits
- Items that look identical are interchangeable, so only distinct sequences are counted.
- There are at most 100 items in total. Counts are exact, with no rounding, however large.
- Ranks start at 1 on this page. The note under each result also gives the zero-based count of arrangements before it.
- Spaces are ignored when each character is an item; use commas to treat words as items.
Frequently asked questions
How do I count the anagrams of a word?
Type the word and keep the setting on each character. The number shown is the number of distinct anagrams including the word itself. Real words are only a small part of them, since most arrangements are not words.
What does it mean to pick fewer items than the total?
It counts distinct sequences of that length that can be formed from the items you have. For three letters from MISSISSIPPI, for example, SSS is possible but MMM is not, because there is only one M.
Why is the rank computed instead of listing everything?
A list of 34,650 arrangements is already long, and a word of 20 letters can have trillions. Ranking adds up block sizes place by place, which takes a fraction of a second whatever the size.
Can I list every arrangement?
The page shows the first few. To see any other one, use the arrangement-by-rank mode and enter its position. Together with the count, that reaches every arrangement.