# Number of ways numbered cards can be picked such that sum of cards equals to a number

I have 3 types of cards, blue, red and green.

The blue cards are labelled 3 to 9, the red cards are labelled 4 to 8, and the green cards are labelled 3 to 7.

I need to find how many ways I can pick the 1 blue card, followed by 1 red card, followed by one green card, such that the sum of the number of all 3 cards is 16.

So far, I tried to manually count the number of combinations that add up to 16, and I got 22.

I was thinking there is probably a better way to count this using combinatorics, like setting the blue card to be 3 first, then using combinatorics to calculate the number of possible combinations of the red and green cards to add up to 16 - value on the blue card. However I realized that this method involves some manual counting too.

I was wondering if there is another way I am able to count the number of ways, using combinatorics methods?

• Hint: you are trying to find the number of integer solutions to $x_1+x_2+x_3=16$ with $3\leq x_1 \leq 9$, $4\leq x_2 \leq 9$ and $3\leq x_3 \leq 7$. There are known methods to solve this kind of problems. Did you try any?
– YJT
Commented Sep 11, 2020 at 8:03
• @YJT hello! the thing is I do not know any methods thats why I am asking Commented Sep 11, 2020 at 8:12
• brilliant.org/wiki/integer-equations-star-and-bars
– YJT
Commented Sep 11, 2020 at 8:14

Let $$b, g, r$$ denote, respectively, the numbers on the blue, green, and red cards. Then we want to find the number of solutions of the equation $$b + g + r = 16 \tag{1}$$ subject to the restrictions $$3 \leq b \leq 9$$, $$3 \leq g \leq 7$$, and $$4 \leq r \leq 8$$.

We can convert this to the equivalent problem in the nonnegative integers. Let $$b' = b - 3$$, $$g' = g - 3$$, and $$r' = r - 4$$. Then $$b'$$, $$g'$$, and $$r'$$ are nonnegative integers satisfying $$b' \leq 6$$, $$g' \leq 4$$, $$r' \leq 4$$. Substituting $$b' + 3$$ for $$b$$, $$g' + 3$$ for $$g$$, and $$r' + 4$$ for $$r$$ in equation 1 yields \begin{align*} b' + 3 + g' + 3 + r' + 4 & = 16\\ b' + g' + r' & = 6 \tag{2} \end{align*} Equation 2 is an equation in the nonnegative integers. A particular solution of equation 2 corresponds to the placement of $$3 - 1 = 2$$ addition signs in a row of six ones. For instance, $$1 1 1 + 1 1 + 1$$ corresponds to the solution $$b' = 3, g' = 2, r' = 1$$ of equation 2 and $$b = 6, g = 5, r = 5$$ of equation 1, while $$+ 1 1 + 1 1 1 1$$ corresponds to the solution $$b' = 0, g' = 2, r' = 4$$ of equation 2 and $$b = 3, g = 5, r = 8$$ of equation 1. The number of solutions of equation 2 in the nonnegative integers is the number of ways we can insert $$3 - 1 = 2$$ addition signs in a row of $$6$$ ones, which is $$\binom{6 + 3 - 1}{3 - 1} = \binom{8}{2}$$ since we must choose which $$2$$ of the $$8$$ positions required for six ones and two addition signs will be filled with addition signs.

However, these solutions include those that violate the restrictions $$g' \leq 4$$ or $$r' \leq 4$$. Notice that both restrictions cannot be violated simultaneously since $$2 \cdot 5 > 6$$.

There are two ways to select the variable which exceeds $$4$$. Suppose it is $$g'$$. Then $$g'' = g' - 5$$ is a nonnegative integer. Substituting $$g'' + 5$$ for $$g'$$ in equation 2 yields \begin{align*} b' + g'' + 5 + r' & = 6\\ b' + g'' + r' & = 1 \tag{3} \end{align*} Equation 3 is an equation in the nonnegative integers with $$\binom{1 + 3 - 1}{3 - 1} = \binom{3}{2}$$ solutions. Hence, there are $$\binom{2}{1}\binom{3}{2}$$ solutions of equation 2 which violate the restriction $$g' \leq 4$$ or $$r' \leq 4$$.

Therefore, the number of admissible solutions of equation 2 is $$\binom{8}{2} - \binom{2}{1}\binom{3}{2} = 22$$ as you found.

• Thank you so much! Is there a name for this method? Commented Sep 11, 2020 at 8:11
• I reduced the problem to a combination with repetition problem by converting it to a problem in the nonnegative integers. I used the technique stars and bars (in particular, Theorem 2) to solve the problem in the nonnegative integers. Finally, I used the Inclusion-Exclusion Principle to handle the remaining restrictions. Commented Sep 11, 2020 at 8:18

There is an (arguably) better way, but it is somewhat convoluted.

There are 7 choices for the blue card and 5 choices for the red card, for a total of 35 possible blue x red combinations.

For each of the 35 combinations, either there is a unique satisfying green card, or there isn't. So all you have to do is identify which of the 35 combinations permit no satisfying green card.

A blue x red combination will permit a satisfying green combination if and only if the blue + red is in the interval $$\{9, 10, 11, 12, 13\}.$$

So all you have to do is create a chart of the various possible blue cards. With each such blue card, how many red cards will not permit a satisfying green card.

The chart should look like this:
Blue # : # Red cards that force dis-satisfaction
3 : 2
4 : 1
5 : 0
6 : 1
7 : 2
8 : 3
9 : 4

Adding up the # of dis-satisfying possibilities (i.e. 2nd column) from the above chart gives 13.
35 - 13 = 22.

Note, that although it appears that the chart was manually drawn, all you really have to do is notice that:

(a)
When blue = 5, every red allows satisfaction.

(b)
As blue increases or decreases from 5, the # of reds that force dis-satisfaction increase by 1.