I'm working on a Google Sheets spreadsheet, and I'm having trouble figuring out a way to count all possible ways a set of (concrete) values could be sorted, taking into account possible duplicate values.
For example, if I have a list of 3 values A,A,B
, I want to know how many ways I could shuffle them around. In this case the result would be (in no particular order):
A,A,B
A,B,A
B,A,A
so 3 total combinations.
I am trying to figure out what formula I could use to input such a list and get the total combinations. I've tried to build formulas using COMBIN
, COMBINA
, PERMUT
and MULTINOMIAL
, combined with COUNTUNIQUE
and COUNTA
, but so far none of the results match what I expect (3).
Is this such an uncommon need? I thought it would be a well-known formula with many uses. e.g. to calculate the theoretical maximum of anagrams of a word, or counting the number of possible states of a shuffled deck of cards, etc. Maybe I'm missing the proper name for this operation?
I tried reading the Wikipedia articles on Binomial coefficient and Permutation, but they are quite hard to read.
I am comfortable building formulas on Google Sheets once I have a mental picture of the required steps, but what's frustrating me is that I can intuitively make sense of the problem and obtain the solution manually by exhaustively enumerating all the possibilities, but can't figure out how to convert that process into a generic mathematical equation. Any hints?
n-tuple
.From a Set containing k elements(A,B),the number of possible n-tuples =k^n
= 2^3 = 8. Thisk^n
is only valid,Where no restrictions are placed on the repetition,i.e., (A,A,A),(B,B,A),(B,A,B),etc. are all possible. You're looking@n-tuples with restriction on repetition on both elements(A:2,B:1)