0

Imagine that I have a group with elements {A,A,B,C,D} and I want to generate all non-ordenated possible combinantions with 2 letters. They are {A,A}, {A,B}, {A,C}, {A,D}, {B,C}, {B,D} and {C,D}.

Is it possible to calculte this number in general (a group of $k$ elements: $n_1$ elements $A_1$, $n_2$ elements $A_2$ ... with $\sum n_i=k$)?

I guess it will be something related with combinatorics numbers. However, I can't figure out a general formula.

My specific case is groups of 5, 6, 7, 8 and 9 elements from group {A,A,A,A,B,B,C,D,E}

  • 1
    Note: "group" has a precise meaning in mathematics, here you just mean "collection" or "multiset". Also, I suspect you meant "unordered" when you wrote "non-ordenated". – lulu Mar 15 '23 at 22:23
  • The answer you want is, in general, going to depend on some arithmetic between the total number of desired elements and the $n_i$. Best, perhaps, to work recursively: For each possible number of $A_k$, you can build the rest of your multiset recursively from a smaller multiset. – lulu Mar 15 '23 at 22:27
  • Consider the use of generating functions. For your specific case, consider the function $(1+x+x^2+x^3+x^4)(1+x+x^2)(1+x)(1+x)(1+x)$, expanding that, and looking at the coefficient of the corresponding term, for instance the expansion here has $23x^5$ so there are $23$ size five "combinations" available to you. – JMoravitz Mar 16 '23 at 00:26
  • @JMoravitz So elegant, that I deleted my comments. – user2661923 Mar 16 '23 at 18:32

0 Answers0