TExcelTAD
Home › School Probability & Statistics on Paper › Solving Classical High School Counting Problems

Solving Classical High School Counting Problems

In high school examinations and mathematics competitions, counting problems rarely come labeled with the formula you should use. Instead, they are presented as rich, real-world word problems: travelers navigating grid city streets, bakers distributing cookies into gift boxes, or school committees subject to intricate friendship and rivalry constraints.

The challenge is not calculating the arithmetic—it is identifying the structural model behind the words.

In this lesson, we synthesize all counting tools from this chapter and introduce the Big Three Advanced Paper Models:

  1. Lattice Paths (Grid Walking)
  2. Stars and Bars (Balls in Bins)
  3. The Pigeonhole Principle (Worst-Case Logic)

1. Grid Walking (Lattice Paths)

Suppose a city consists of a rectangular grid of streets. You start at the southwest corner (0,0)(0, 0) and wish to travel to the northeast corner (m,n)(m, n). At each intersection, you may only walk Right (RR) or Up (UU).

(0,n) ┌───┬───┬───┐ (m,n)
      │   │   │   │
      ├───┼───┼───┤
      │   │   │   │
(0,0) └───┴───┴───┘ (m,0)
  • Any valid path requires walking exactly mm Right steps and nn Up steps.
  • The total number of steps is always m+nm + n.
  • A complete path is uniquely determined by choosing which mm of the total m+nm + n steps are Right steps (RR).
Total Paths from (0,0) to (m,n)=(m+nm)=(m+nn)\begin{aligned} \text{Total Paths from } (0,0) \text{ to } (m,n) = \binom{m + n}{m} = \binom{m + n}{n} \end{aligned}

Passing Through a Mandatory Checkpoint C(x0,y0)C(x_0, y_0)

If you must visit checkpoint C(x0,y0)C(x_0, y_0) along the way:

  1. Count paths from (0,0)(0, 0) to (x0,y0)(x_0, y_0): (x0+y0x0)\binom{x_0 + y_0}{x_0}.
  2. Count paths from (x0,y0)(x_0, y_0) to (m,n)(m, n): ((m−x0)+(n−y0)m−x0)\binom{(m - x_0) + (n - y_0)}{m - x_0}.
  3. Multiply the two counts using the Multiplication Principle.

2. Stars and Bars (Distributing Identical Items)

A classic problem is distributing nn identical objects into kk distinct bins.

Because the objects are identical, we cannot use permutations. Instead, we use the method of Stars and Bars:

  • Represent the nn items as stars (⋆\star).
  • Separate the items into kk bins using k−1k - 1 dividers or bars (∣|).

Example: Distributing 77 identical candies among 33 children:

Child 1      Child 2      Child 3
 ★★     |      ★★★    |     ★★

Here, Child 1 gets 22, Child 2 gets 33, and Child 3 gets 22.

The total number of symbols is nn stars +(k−1)+ (k - 1) bars =n+k−1= n + k - 1.
The number of ways is simply choosing where to place the k−1k - 1 bars:

Non-negative integer solutions (xi≥0):(n+k−1k−1)\begin{aligned} \text{Non-negative integer solutions } (x_i \ge 0): \quad \binom{n + k - 1}{k - 1} \end{aligned}

Case 2: Every Bin Must Receive At Least One Item (xi≥1x_i \ge 1)

If every child must receive at least 11 candy, place the k−1k - 1 bars into the n−1n - 1 available spaces between the nn stars:

Positive integer solutions (xi≥1):(n−1k−1)\begin{aligned} \text{Positive integer solutions } (x_i \ge 1): \quad \binom{n - 1}{k - 1} \end{aligned}

3. The Pigeonhole Principle (Dirichlet's Principle)

The Pigeonhole Principle:
If NN items (pigeons) are placed into kk containers (pigeonholes), and N>kN > k, then at least one container must contain at least two items.

The General Ceiling Form

If NN items are distributed into kk containers, at least one container must contain at least:

⌈Nk⌉ items\begin{aligned} \left\lceil \frac{N}{k} \right\rceil \text{ items} \end{aligned}

(where ⌈x⌉\lceil x \rceil is the ceiling function, rounding up to the nearest integer).

Paper Technique: The "Worst-Case Scenario" (Adversary Thinking)

When an exam asks: "What is the minimum number of items you must draw to guarantee...", always assume the universe is conspiring against you. Calculate the worst possible luck first, and then add 11.


Formula Box

Lattice Paths from (0,0)→(m,n):(m+nm)Paths through Checkpoint C(x0,y0):(x0+y0x0)×((m−x0)+(n−y0)m−x0)Stars & Bars (Non-negative xi≥0):(n+k−1k−1)Stars & Bars (Positive xi≥1):(n−1k−1)Pigeonhole Guarantee:⌈Nk⌉\begin{aligned} &\textbf{Lattice Paths from } (0,0) \to (m,n)\textbf{:} && \binom{m + n}{m} \\ &\textbf{Paths through Checkpoint } C(x_0, y_0)\textbf{:} && \binom{x_0 + y_0}{x_0} \times \binom{(m - x_0) + (n - y_0)}{m - x_0} \\ &\textbf{Stars \& Bars (Non-negative } x_i \ge 0\textbf{):} && \binom{n + k - 1}{k - 1} \\ &\textbf{Stars \& Bars (Positive } x_i \ge 1\textbf{):} && \binom{n - 1}{k - 1} \\ &\textbf{Pigeonhole Guarantee:} && \left\lceil \frac{N}{k} \right\rceil \end{aligned}

Step-by-Step Paper Notebook Method: The Model Selector

Are the items distinct or identical?
   │
   ├─► DISTINCT ITEMS:
   │      └── Does order matter?
   │             ├── YES: Permutations P(n, k) or Slots
   │             └── NO:  Combinations \binom{n}{k}
   │
   └─► IDENTICAL ITEMS:
          └── Are they placed into distinct containers/bins?
                 ├── YES: Stars & Bars
                 │          ├── If x_i >= 0 ──► \binom{n + k - 1}{k - 1}
                 │          └── If x_i >= 1 ──► \binom{n - 1}{k - 1}
                 └── NO:  Integer Partitions

Worked Examples

Example 1: Grid Walking with an Avoided Intersection

Problem:
A robot starts at (0,0)(0, 0) and moves on a grid to (5,4)(5, 4) using only unit steps Right (RR) and Up (UU).

  1. How many total paths exist?
  2. How many paths pass through the checkpoint P(2,2)P(2, 2)?
  3. How many paths avoid the flooded intersection P(2,2)P(2, 2)?

Solution & Paper Work:

  • Part 1: Total paths without restrictions:
    Total Right steps m=5m = 5, total Up steps n=4n = 4.
    Total steps =5+4=9= 5 + 4 = 9.
Ntotal=(94)=9×8×7×64×3×2×1=9×2×7=126\begin{aligned} N_{\text{total}} = \binom{9}{4} = \frac{9 \times 8 \times 7 \times 6}{4 \times 3 \times 2 \times 1} = 9 \times 2 \times 7 = 126 \end{aligned}
  • Part 2: Paths passing through P(2,2)P(2, 2):
    • Stage 1: From (0,0)(0, 0) to (2,2)(2, 2) (22 Right, 22 Up   ⟹  4\implies 4 steps):
Nstart→P=(42)=4×32×1=6\begin{aligned} N_{\text{start} \to P} = \binom{4}{2} = \frac{4 \times 3}{2 \times 1} = 6 \end{aligned}
  • Stage 2: From (2,2)(2, 2) to (5,4)(5, 4) (33 Right, 22 Up   ⟹  5\implies 5 steps):
NP→end=(52)=5×42×1=10\begin{aligned} N_{P \to \text{end}} = \binom{5}{2} = \frac{5 \times 4}{2 \times 1} = 10 \end{aligned}
  • Multiply stages:
Nthrough P=6×10=60\begin{aligned} N_{\text{through } P} = 6 \times 10 = 60 \end{aligned}
  • Part 3: Paths avoiding P(2,2)P(2, 2):
    Use the Complement Principle:
Navoiding P=Ntotal−Nthrough P=126−60=66\begin{aligned} N_{\text{avoiding } P} = N_{\text{total}} - N_{\text{through } P} = 126 - 60 = 66 \end{aligned}
  • Final Answer:
    1. Total: 126126 paths
    2. Through P(2,2)P(2, 2): 6060 paths
    3. Avoiding P(2,2)P(2, 2): 6666 paths

Example 2: Distributing Cookies (Stars and Bars)

Problem:
A baker has 1212 identical chocolate chip cookies to distribute among 44 children.

  1. In how many ways can they be distributed if some children may receive zero cookies?
  2. In how many ways can they be distributed if each child must receive at least 11 cookie?

Solution & Paper Work:

  • Part 1: Zero cookies allowed (xi≥0x_i \ge 0):
    Here n=12n = 12 cookies, k=4k = 4 children.
    Number of bars =k−1=4−1=3= k - 1 = 4 - 1 = 3.
    Total slots =n+k−1=12+3=15= n + k - 1 = 12 + 3 = 15.
N=(153)=15×14×133×2×1=5×7×13=455\begin{aligned} N = \binom{15}{3} = \frac{15 \times 14 \times 13}{3 \times 2 \times 1} = 5 \times 7 \times 13 = 455 \end{aligned}
  • Part 2: Each child receives at least 1 cookie (xi≥1x_i \ge 1):
    Method A (Stars and Bars gaps):
    1212 stars create 12−1=1112 - 1 = 11 spaces. We place k−1=3k - 1 = 3 bars:
N=(12−14−1)=(113)=11×10×93×2×1=11×5×3=165\begin{aligned} N = \binom{12 - 1}{4 - 1} = \binom{11}{3} = \frac{11 \times 10 \times 9}{3 \times 2 \times 1} = 11 \times 5 \times 3 = 165 \end{aligned}

Method B (Pre-allocation shortcut):
Give 11 cookie to each child upfront (44 cookies used).
Now distribute the remaining 12−4=812 - 4 = 8 cookies freely among the 44 children (xi′≥0x'_i \ge 0):

N=(8+4−14−1)=(113)=165\begin{aligned} N = \binom{8 + 4 - 1}{4 - 1} = \binom{11}{3} = 165 \end{aligned}

Both methods produce 165165!

  • Final Answer:
    1. xi≥0x_i \ge 0: 455455 ways
    2. xi≥1x_i \ge 1: 165165 ways

Example 3: The Sock Drawer (Pigeonhole Worst-Case)

Problem:
In a dark room, a drawer contains 1010 red socks, 1414 blue socks, and 88 black socks (all identical in texture and size).

  1. What is the minimum number of socks you must pull out to guarantee at least one matching pair?
  2. What is the minimum number of socks you must pull out to guarantee at least one matching pair of blue socks?

Solution & Paper Work:

  • Part 1: Any matching pair:
    • Identify the "holes" (colors): Red, Blue, Black   ⟹  k=3\implies k = 3 categories.
    • Worst-case scenario: You pull out 11 Red, 11 Blue, and 11 Black sock (33 socks drawn, zero matching pairs).
    • By the Pigeonhole Principle, the very next sock (4th4\text{th} sock) must match one of the three colors already drawn:
Nmin⁡=3+1=4 socks\begin{aligned} N_{\min} = 3 + 1 = 4 \text{ socks} \end{aligned}
  • Part 2: Specifically a blue pair:
    • The worst-case adversary will deliberately give you all non-blue socks first!
    • Non-blue socks: 1010 Red +8+ 8 Black =18= 18 socks.
    • You could draw all 1818 non-blue socks without obtaining even a single blue sock!
    • Then, the 19th19\text{th} sock is guaranteed to be Blue.
    • The 20th20\text{th} sock is guaranteed to be a second Blue sock.
Nmin⁡=10(Red)+8(Black)+2(Blue)=20 socks\begin{aligned} N_{\min} = 10 (\text{Red}) + 8 (\text{Black}) + 2 (\text{Blue}) = 20 \text{ socks} \end{aligned}
  • Final Answer:
    1. Any matching pair: 44 socks
    2. A pair of blue socks: 2020 socks

Common Paper Traps

Trap Danger on Paper Corrective Technique
Using Stars & Bars on Distinct Items Using (n+k−1k−1)\binom{n+k-1}{k-1} when distributing 44 distinct books among 33 students. Stars and bars applies only when items are identical. If items are distinct, each item has kk independent choices   ⟹  kn\implies k^n ways.
Ignoring Intermediate Multiplications Adding path counts through a point instead of multiplying them. Going from A→P→BA \to P \to B is a two-stage sequential journey   ⟹  \implies multiply $
Optimistic Pigeonhole Thinking Answering "22 socks" because you "could get lucky on the first two draws". Guarantee questions require worst-case adversary analysis. What is the worst that can happen before the condition is forced?

Pencil & Paper Practice

  1. Lattice Paths: How many routes exist from (0,0)(0, 0) to (6,3)(6, 3) on a grid if the traveler can only move Right or Up?
  2. Integer Equations: Find the number of integer solutions to the equation:
x1+x2+x3+x4=15where xi≥1 for each i∈{1,2,3,4}\begin{aligned} x_1 + x_2 + x_3 + x_4 = 15 \quad \text{where } x_i \ge 1 \text{ for each } i \in \{1, 2, 3, 4\} \end{aligned}
  1. Pigeonhole Birthdays: How many students must be in a lecture hall to guarantee that at least two of them share the same birth month?

Worked Solutions

Solution 1

  • Right steps m=6m = 6, Up steps n=3n = 3. Total steps =6+3=9= 6 + 3 = 9.
(93)=9×8×73×2×1=3×4×7=84\begin{aligned} \binom{9}{3} = \frac{9 \times 8 \times 7}{3 \times 2 \times 1} = 3 \times 4 \times 7 = 84 \end{aligned}

Result: 8484 routes.

Solution 2

  • This is distributing n=15n = 15 identical units into k=4k = 4 variables with xi≥1x_i \ge 1:
N=(n−1k−1)=(15−14−1)=(143)=14×13×123×2×1=14×13×2=364\begin{aligned} N = \binom{n - 1}{k - 1} = \binom{15 - 1}{4 - 1} = \binom{14}{3} = \frac{14 \times 13 \times 12}{3 \times 2 \times 1} = 14 \times 13 \times 2 = 364 \end{aligned}

Result: 364364 solutions.

Solution 3

  • There are k=12k = 12 months in a year.
  • By the Pigeonhole Principle, if N=12N = 12, every student could have a different birth month (worst-case).
  • The (12+1)=13th(12 + 1) = 13\text{th} student must share a month with one of the others:
N=12+1=13\begin{aligned} N = 12 + 1 = 13 \end{aligned}

Result: 1313 students.


Test yourself

How many paths are there from (0,0)(0, 0) to (4,3)(4, 3) on a grid moving only Right and Up?

  1. 1212
  2. 3535
  3. 7070
  4. 2121

How many non-negative integer solutions (xi≥0x_i \ge 0) exist for the equation x1+x2+x3=8x_1 + x_2 + x_3 = 8?

  1. (102)=45\binom{10}{2} = 45
  2. (82)=28\binom{8}{2} = 28
  3. (113)=165\binom{11}{3} = 165
  4. (72)=21\binom{7}{2} = 21

A bag contains 55 red marbles, 77 green marbles, and 99 yellow marbles. What is the minimum number of marbles you must draw without looking to guarantee at least one marble of each color?

  1. 33
  2. 1717
  3. 1616
  4. 1515