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:
- Lattice Paths (Grid Walking)
- Stars and Bars (Balls in Bins)
- 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 and wish to travel to the northeast corner . At each intersection, you may only walk Right () or Up ().
(0,n) ┌───┬───┬───┐ (m,n)
│ │ │ │
├───┼───┼───┤
│ │ │ │
(0,0) └───┴───┴───┘ (m,0)- Any valid path requires walking exactly Right steps and Up steps.
- The total number of steps is always .
- A complete path is uniquely determined by choosing which of the total steps are Right steps ().
Passing Through a Mandatory Checkpoint
If you must visit checkpoint along the way:
- Count paths from to : .
- Count paths from to : .
- Multiply the two counts using the Multiplication Principle.
2. Stars and Bars (Distributing Identical Items)
A classic problem is distributing identical objects into distinct bins.
Because the objects are identical, we cannot use permutations. Instead, we use the method of Stars and Bars:
- Represent the items as stars ().
- Separate the items into bins using dividers or bars ().
Example: Distributing identical candies among children:
Child 1 Child 2 Child 3
★★ | ★★★ | ★★Here, Child 1 gets , Child 2 gets , and Child 3 gets .
The total number of symbols is stars bars .
The number of ways is simply choosing where to place the bars:
Case 2: Every Bin Must Receive At Least One Item ()
If every child must receive at least candy, place the bars into the available spaces between the stars:
3. The Pigeonhole Principle (Dirichlet's Principle)
The Pigeonhole Principle:
If items (pigeons) are placed into containers (pigeonholes), and , then at least one container must contain at least two items.
The General Ceiling Form
If items are distributed into containers, at least one container must contain at least:
(where 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 .
Formula Box
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 PartitionsWorked Examples
Example 1: Grid Walking with an Avoided Intersection
Problem:
A robot starts at and moves on a grid to using only unit steps Right () and Up ().
- How many total paths exist?
- How many paths pass through the checkpoint ?
- How many paths avoid the flooded intersection ?
Solution & Paper Work:
- Part 1: Total paths without restrictions:
Total Right steps , total Up steps .
Total steps .
- Part 2: Paths passing through :
- Stage 1: From to ( Right, Up steps):
- Stage 2: From to ( Right, Up steps):
- Multiply stages:
- Part 3: Paths avoiding :
Use the Complement Principle:
- Final Answer:
- Total: paths
- Through : paths
- Avoiding : paths
Example 2: Distributing Cookies (Stars and Bars)
Problem:
A baker has identical chocolate chip cookies to distribute among children.
- In how many ways can they be distributed if some children may receive zero cookies?
- In how many ways can they be distributed if each child must receive at least cookie?
Solution & Paper Work:
- Part 1: Zero cookies allowed ():
Here cookies, children.
Number of bars .
Total slots .
- Part 2: Each child receives at least 1 cookie ():
Method A (Stars and Bars gaps):
stars create spaces. We place bars:
Method B (Pre-allocation shortcut):
Give cookie to each child upfront ( cookies used).
Now distribute the remaining cookies freely among the children ():
Both methods produce !
- Final Answer:
- : ways
- : ways
Example 3: The Sock Drawer (Pigeonhole Worst-Case)
Problem:
In a dark room, a drawer contains red socks, blue socks, and black socks (all identical in texture and size).
- What is the minimum number of socks you must pull out to guarantee at least one matching pair?
- 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 categories.
- Worst-case scenario: You pull out Red, Blue, and Black sock ( socks drawn, zero matching pairs).
- By the Pigeonhole Principle, the very next sock ( sock) must match one of the three colors already drawn:
- Part 2: Specifically a blue pair:
- The worst-case adversary will deliberately give you all non-blue socks first!
- Non-blue socks: Red Black socks.
- You could draw all non-blue socks without obtaining even a single blue sock!
- Then, the sock is guaranteed to be Blue.
- The sock is guaranteed to be a second Blue sock.
- Final Answer:
- Any matching pair: socks
- A pair of blue socks: socks
Common Paper Traps
| Trap | Danger on Paper | Corrective Technique |
|---|---|---|
| Using Stars & Bars on Distinct Items | Using when distributing distinct books among students. | Stars and bars applies only when items are identical. If items are distinct, each item has independent choices ways. |
| Ignoring Intermediate Multiplications | Adding path counts through a point instead of multiplying them. | Going from is a two-stage sequential journey multiply $ |
| Optimistic Pigeonhole Thinking | Answering " 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
- Lattice Paths: How many routes exist from to on a grid if the traveler can only move Right or Up?
- Integer Equations: Find the number of integer solutions to the equation:
- 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 , Up steps . Total steps .
Result: routes.
Solution 2
- This is distributing identical units into variables with :
Result: solutions.
Solution 3
- There are months in a year.
- By the Pigeonhole Principle, if , every student could have a different birth month (worst-case).
- The student must share a month with one of the others:
Result: students.
Test yourself
How many paths are there from to on a grid moving only Right and Up?
How many non-negative integer solutions () exist for the equation ?
A bag contains red marbles, green marbles, and yellow marbles. What is the minimum number of marbles you must draw without looking to guarantee at least one marble of each color?