Permutations of elements where some elements are of the same kind

combinatorics

I want to find the number of permutations for element sets like AABC, AABBC, AABBCCFQQQ, etc. Element sets where there are distinct elements, whose placement relative to each other matters, but also identical elements (sub-sets of the element set), within which order doesn't matter. Put shortly, order matters within the element set, but not within the individual sub-sets.

In the case of AABC, there's four element spaces. If one is only directly moving the A-elements (and thus indirectly displacing the other elements), one gets six permutations. That makes sense because you're choosing two places out of four, and order doesn't matter: $\frac{4!}{(4-2)!2!}$, which is six. With the other elements, you're choosing one place out of four: $\frac{4!}{(4-1)!1!}$, which is four. So I thought, maybe the total number of permutations is all of these combinations added together?

AABC …… Copy 1A

ABAC

ABCA

BAAC

BACA

BCAA …… Copy 1B


BCAA …… Copy 2B

CBAA

CABA

CAAB …… Copy 1C


CAAB …… Copy 2C

ACAB

AACB

AABC …… Copy 2A

There are six copies, which divided by two yields three superfluous. Adding everything together, and subtracting three, gives eleven as the total number of permutations. This has led me to believe that this equation may give the answer. $$\frac{\text{No. elements}!}{(\text{No. elements} – \text{No. e}_1)! \ \ \text{No. e}_1!} + … + \frac{\text{No. elements}!}{(\text{No. elements} – \text{No. e}_n)! \ \ \text{No. e}_n!} – n$$

If n is greater than 2, n being the number of distinct elements. e$_n$ is the nth element, and e$_1$ is the first element.

I've seen that when n = 2, there is no addition, but simply one combination. I think this may be because no. e$_1 = x$ and e$_2 = y$, $$\frac{(x+y)!}{(x+y-x)!x!} = \frac{(x+y)!}{(x+y-y)!y!}$$

Basically, by directly moving the A-elements through all of their combinations, one is indirectly displacing the B-elements through all of their combinations.

That's all I have, and it should give the answerer a rough notion of my level of combinatorics and math understanding. To conclude, I'm looking for an equation that gives the number of permutations with the input variables of the number of distinct elements, and the individual numbers of the element sub-sets.

EDIT:

I forgot to mention that I was looking for the permutations using all of the letters. Also, my brute force method missed ACBA.

Best Answer

Suppose you have a set of $N$ letters consisting of $k$ distinct letters, the first of which repeated $n_1$ times, the second of which repeated $n_2$ times, and so on up to the $k$'th of which repeated $n_k$ times. So, $n_1+n_2+\dots+n_k=N$. For instance, your AABC example you have $N=4,k=3,n_1=2,n_2=1,n_3=1$ or in your AABBCCFQQQ example you have $N=10,k=5,n_1=2,n_2=2,n_3=2,n_4=1,n_5=3$.

The answer to the question of how many rearrangements of this string exist using some (but not necessarily all) of the letters can be seen in @Bulbasaur's answer here or in 6-letter permutations of MISSISSIPPI and is a more challenging problem than what I expect you are expecting.

As for the far simpler question of how many rearrangements of this string exist using all of the letters, this is precisely what Multinomial Coefficients count.

$$\binom{N}{n_1,n_2,\dots,n_k}=\dfrac{N!}{n_1!n_2!\cdots n_k!}=\binom{N}{n_1}\binom{N-n_1}{n_2}\binom{N-n_1-n_2}{n_3}\cdots\binom{N-n_1-\dots -n_{k-1}}{n_k}$$

These are the coefficients of the $x_1^{n_1}x_2^{n_2}\cdots x_k^{n_k}$ term in the expansion of $(x_1+x_2+\dots+x_k)^N$

A quick handwavy proof is that if you imagine each letter has being uniquely identifiable then we have $N!$ arrangements. Recognizing then that each relabeling of the ids of each respective letter yields another equivalent arrangement so to "forget" which copy of a letter was which we divide by the number of ways to have labeled them which is $n_1!n_2!\cdots n_k!$

Another explanation is that if you were to just choose the spaces used by each letter a group at a time, so... choosing which $n_1$ spaces were used by the first letter out of the $N$, then choosing which $n_2$ spaces were used by the second letter out of the remaining $N-n_1$, and so on... you arrive at the same expression noting the massive algebraic cancellation that can occur.

For your example of $AABC$, there are $\dfrac{4!}{2!1!1!}=12$ different arrangements, this corresponding to the coefficient of the $a^2bc$ term in the expansion of $(a+b+c)^4$

Related Question