Dear forumers,
I dealing with a problem, where I need to count the number of ways that I can choose k element from a multiset.
You have a set with n elements. All of the elements has a given frequency, like:
A1 occurs a1 times, A2 occurs a2 times and so on, where a1+a2+…=n
I would like to choose k elements, the sorting doesn’t matter.
Although I don't want to really choose them, or I don't have an exact set, I'm only interested on the number of ways, if the frequency is given.
https://www.quora.com/If-I-choose-n-elements-from-a-multiset-S-how-many-possible-combinations-orderless-and-sequences-ordered-are-possible
Here you can see a recursive solution in the first answer.
I think I could implement this as a recursive function, if the number of different elements would be always the same. But unfortunately this is often different.
Could somebody help me to make such a function?
I would really-really appreciate Your help! Thank you!