Number of unique ways to select $3$ balls from $4$ red balls, $2$ green balls and $1$ blue ball

684 Views Asked by At

Suppose there is a jar with $7$ balls: $4$ red, $2$ green and $1$ blue.
In how many unique ways can we choose $3$ balls?

Just by considering all the possibilities, I found out the answer is $6$. Namely:

  • red, red, red
  • red, red, green
  • red, red, blue
  • green, green, red
  • green, green, blue
  • blue, green, red

I was wondering if it is possible to express the solution in terms of the amount of different colors (in this case $3$) and the quantity per color. (in this case $4$, $2$ and $1$)

2

There are 2 best solutions below

0
On BEST ANSWER

Consider the polynomial $$\eqalign{p(x)&:=(1+x+x^2+x^3+x^4)(1+x+x^2)(1+x)\cr &=(1-x^5)(1-x^3)(1-x^2)(1-x)^{-3}\cr &=(1-x^5)(1-x^3)(1-x^2)\sum_{k\geq0}{2+k\choose k}x^k\ .\cr}\tag{1}$$ For each admissible choice of $r\in[0 .. 4]$ red balls, $g\in[0 .. 2]$ green balls, and $b\in[0 .. 1]$ blue balls the expansion of this polynomial creates a term $x^r\,x^g\,x^b=x^{r+g+b}$. Now we want $r+g+b=3$. It follows that we have to extract $N:={\rm coeff}[x^3]$ on the last line of $(1)$. Since $$(1-x^5)(1-x^3)(1-x^2)=1-x^2-x^3+{\rm higher\ terms}$$ it follows that $$N={2+3\choose3}-{2+1\choose1}-{2+0\choose0}=6\ .$$

0
On

We can also solve this problem using the inclusion-exclusion principle. Let $r$, $g$, $b$ represent the number of red, green and blue balls respectively. We want to find all solutions of the equation

$r+g+b=3$

Subject to

$\begin{equation} 0 \leq r \leq 4 \\ 0 \leq g \leq 2 \\ 0 \leq b \leq 1 \end{equation}$

Let $A$ be the set of all solutions of $r+g+b=3$, under only the lower bound constraints, that is, $r, g, b \geq 0$. We can find the number of solutions of $A$ by treating it as a typical "unordered selection with repetition"-problem. (This is analogous to the number of ways to divide 3 items into 3 boxes). $|A| = {3+3-1\choose 3-1} = 10$

Let $R$, $G$, $B$ be the set of solutions that violate the upper bound constraints of the red, green and blue balls respectively.

$R$ has the additional constraint that $r \geq 5$. Then, $r+g+b\geq 5 > 3$, so $|R|=0$

$G$ has the additional constraint that $g \geq 3$. This means $g=3$ and $r=b=0$, so $|G|=1$

$B$ has the additional constraint that $b \geq 2$. Let $b'=b-2$, then the problem becomes $r+g+b' = 1$ s.t. $r, g, b' \geq 0$. This problem has ${1+3-1\choose 3-1} = 3$ solutions.

To apply the inclusion exclusion principle, we also need to solve for all combinations of $R, G, B$. By similar reasoning, we can show that $|R \cap G| = |G \cap B| = |R \cap B| = |R \cap G \cap B| = 0$.

Now we find the solution of the problem with the original constraints by subtracting the solutions that violated the upper bounds from $A$ and applying the inclusion-exclusion principle:

$\begin{align} |A| - |R \cup G \cup B| &= |A| - |R| - |G| - |B| + |R \cap G| + |G \cap B| + |R \cap B| - |R \cap G \cap B| \\ &= 10 - 0 - 1 - 3 + 0 + 0 + 0 - 0 \\ &= 6 \end{align}$