[Math] combinations with repetitions allowed, order does not matter, n less than k

combinationscombinatorics

A machine produces a $9$-digit code from the numbers $\{1,2,3,4,5,6\}$. So, $k=9$ and $n=6$. Repetition is allowed, so the machine could produce $111111112$. However, the order does not matter. So, the machine would consider $111111112$ the same as $211111111$ or $111121111$.

Thus, the number of possible combinations would not simply be $6^9$ as that would be double (or even more) counting certain sequences. How many combinations are there?

Best Answer

What you are looking for is the Stars and Bars method. This method is used to count things where order does not matter and repetition is allowed.

We are choosing $9$ digits from $\{1,2,3,4,5,6\}$

Let me explain how we can get to the answer.

For example, let's say we want to pick the combination $123456123$. This can be "arranged" as such:

$$••|••|••|•|•|•$$

We picked $2$ ones, $2$ twos, $2$ threes, and $1$ of the rest.

Let's look at another possibility: $111222456$ $$•••|•••| |•|•|•$$

We have three ones, three twos, and one $4$, $5$, and $6$.

Look at what these pictures are showing: we have $14$ symbols and we are choosing $5$ of them to be a bar. Or we could look at it as choosing $9$ of them to be a dot (star)

So the answer to our original question is $$\binom{14}{9} = \binom{14}{5} = 2002$$