[Math] Counting problem: selecting $n$ objects among $k$ infinite collections.

combinationscombinatorics

Here's a counting question that got me thinking. Unfortunately, I couldn't get around it. Need help.

You are given $k$ distinct coloured boxes. In each box, lies infinite balls of the same colour as of the box. All the balls of a particular colour are exact copies. You are asked to choose $n$ balls from the whole collection. While making the selection, remember that you need to have $1$ ball of each colour at least. In how many total ways, can you make the selection?


Example. If there are 3 coloured boxes — red, green & blue — then there will be infinite red balls in the first (red) box, infinite green balls in second (green) box and so on…

Now you are asked to choose $5$ balls, then there is $6$ ways to do so.

r g b r r

r g b g g

r g b b b

r g b r g

r g b g b

r g b b r

(I hope I didn't missed any case in the example)

Best Answer

The first thing to notice about this question is that from the chosen $n$ balls, there are $k$ balls that are always the same, due to the requirement of at least on ball each being required - In effect, we are choosing combinations from only $n-k$ balls.

The next thing to note is that from this is that the combinations are unordered and repetition is allowed. There is a general formula for this case:

$$\binom{n + r -1}{r} = \frac{(n+r-1)!}{(n-1)! \cdot r!}$$

Where $n$ is the number of objects to choose from, $r$ is the amount of items we choose, $\binom{n}{k}$ the binomial coefficient and $x!$ the factorial of $x$. An explanation of the formula can be found under this link, near the bottom.

In our case, the $n$ in the formula is unfortunately your $k$, the amount of boxes, and $r$ is $n-k$. In effect:

$$\text{Amount of selections:} \binom{k + n-k - 1}{n-k} = \binom{n-1}{n-k}$$

Putting in $n = 5$ and $k = 3$, this does indeed come up to $6$.

Related Question