# Combinations with duplicate elements [duplicate]

If I have $$~18~$$ cards: $$~1,~1,~1,~2,~2,~2,~3,~3,~3,~4,~4,~4,~5,~5,~5,~6,~6,~6~$$ how many different hands of $$~9~$$ cards are possible. The order of the cards does not matter.

So $$~1,~4,~5,~3,~6,~2,~4,~2,~2~$$ is the same as $$~1,~2,~2,~2,~3,~4,~4,~5,~6~$$ etc so they should not be counted as different hands.

I've looked everywhere but I cannot find any relevant information which could help me. I can only find either answers for simpler questions or answers for incredibly harder questions when I looked and the answer (to me) doesn't seem obvious.

Edit: This question is similar though subtly different from the 10 cards out of a super deck as in this question the size of the hand exceeds the number of duplicate elements making it a much more complex question.

## marked as duplicate by vonbrand, mrtaurho, Feng Shao, The Count, nmasantaAug 28 at 1:48

• @PsychoCom this is not a duplicate of that, but is related. See my comment on the linked question where I point out that the handsize in that problem is less than or equal to the number of copies of each individual card, a very convenient property. We in that problem could never "run out" of any particular type of card. This problem however we can run out of a particular type of card which complicates matters. Still, with correct application of inclusion-exclusion, the techniques used there can be salvaged. – JMoravitz Aug 27 at 13:09

If you don't mind using computers to help., this would be the coefficient of the $$x^9$$ term in the expansion of $$(1+x+x^2+x^3)^6$$ which would be $$580$$.
$$\binom{9+6-1}{6-1}-6\binom{5+6-1}{6-1}+\binom{6}{2}\binom{1+6-1}{6-1}=580$$