CS311H Syllabus Calendar Office Hours Readings Assignments Resources

CS311H Discrete Mathematics for Computer Science

In-Class Activity: Combinatorics – Solutions

Oct 29, 2026


Problem 1

Perform these actions in order: flip a coin, roll a six-sided die, and select one card from a standard deck of 52 cards. Determine the number of outcomes:

  1. With no restrictions.

    Show solution

    The coin has 2 outcomes, the die has 6, and the card has 52. By the product rule, there are \(2 \cdot 6 \cdot 52 = 624\) outcomes.

  2. With a die result of 3.

    Show solution

    The die is fixed, so it has 1 outcome. By the product rule, there are \(2 \cdot 1 \cdot 52 = 104\) outcomes.

  3. With an odd die result.

    Show solution

    An odd die result is 1, 3 or 5, so the die has 3 outcomes. By the product rule, there are \(2 \cdot 3 \cdot 52 = 312\) outcomes.

  4. With an odd die result and a king selected.

    Show solution

    The die has 3 outcomes and the card has 4 outcomes (one king in each suit). By the product rule, there are \(2 \cdot 3 \cdot 4 = 24\) outcomes.

Problem 2

Among the integers \(1, 2, \dots, 1000\), how many are divisible by 5? How many are not divisible by 5?

Show solution

The integers in \(1, 2, \dots, 1000\) that are divisible by 5 are \(5 \cdot 1, 5 \cdot 2, \dots, 5 \cdot 200\), so there are \(\left\lfloor \frac{1000}{5} \right\rfloor = 200\) of them.

Every other integer is not divisible by 5, so there are \(1000 - 200 = 800\) integers that are not divisible by 5.

Problem 3

How many permutations of the digits \(0,1,2,3,4,5,6,7,8,9\) are there in which the digits alternate even and odd? (For example, 2183470965.)

Show solution

There are two possible parity patterns:

\[ E\ O\ E\ O\ E\ O\ E\ O\ E\ O \quad \text{or} \quad O\ E\ O\ E\ O\ E\ O\ E\ O\ E. \]

For either pattern, the five even digits can be placed in the five positions marked \(E\) in \(5!\) ways, and the five odd digits can be placed in the five positions marked \(O\) in \(5!\) ways. The two patterns are disjoint, so the count is

\[ 2(5!)(5!) = 28{,}800. \]

A permutation beginning with 0 is included: the question asks for permutations of the digits, rather than 10-digit integers.

Problem 4

How many 10-digit binary strings are there that do not have exactly four 1's?

Show solution

There are \(2^{10}\) binary strings of length ten. A string with exactly four 1's is determined by choosing the four positions occupied by those 1's, so there are \(\binom{10}{4}\) such strings. Subtracting these from the total gives

\[ 2^{10} - \binom{10}{4} = 1024 - 210 = 814. \]

Problem 5

Use \(\binom{n}{k} = \frac{n!}{k!(n-k)!}\) for \(0 \leq k \leq n\) to derive the following: \[ \binom{n+1}{k} = \binom{n}{k-1} + \binom{n}{k}, \qquad 1 \leq k \leq n. \]

Show solution

Using the factorial formula and a common denominator,

\[ \begin{array}{r c l} \binom{n}{k-1} + \binom{n}{k} & = & \frac{n!}{(k-1)!(n-k+1)!} + \frac{n!}{k!(n-k)!} \\ & = & \frac{k\, n! + (n-k+1)\, n!}{k!(n-k+1)!} \\ & = & \frac{(n+1)!}{k!((n+1)-k)!} = \binom{n+1}{k}. \end{array} \]

This is the required equation.

Problem 6

How many 10-digit binary strings begin in 1 or end in 1?

Show solution

Let \(A\) be the strings beginning in 1 and \(B\) the strings ending in 1. Fixing either endpoint leaves nine free digits, so \(|A| = |B| = 2^9\). Fixing both endpoints leaves eight free digits, so \(|A \cap B| = 2^8\). Inclusion-exclusion gives

\[ |A \cup B| = 2^9 + 2^9 - 2^8 = 512 + 512 - 256 = 768. \]

Problem 7

A bag contains 20 identical red balls, 20 identical blue balls, 20 identical green balls, and one white ball. You reach in and grab 15 balls. How many different outcomes are possible?

Show solution

An outcome is determined by the number of balls of each color. Since at most 15 balls are drawn and each color has 20, no color can run out, so the only constraint on the counts is that they are nonnegative. Split into two disjoint cases according to whether the white ball is selected.

Case 1: the white ball is not selected. The counts \((r,b,g)\) satisfy \(r + b + g = 15\) with all counts nonnegative. By stars and bars, there are

\[ \binom{15+3-1}{3-1} = \binom{17}{2} = 136 \]

possibilities.

Case 2: the white ball is selected. The other 14 balls are red, blue or green, so the counts \((r,b,g)\) satisfy \(r + b + g = 14\) with all counts nonnegative. By stars and bars, there are

\[ \binom{14+3-1}{3-1} = \binom{16}{2} = 120 \]

possibilities.

The two cases are disjoint, so by the sum rule there are \(136 + 120 = 256\) different outcomes.