Grid path counting, stairs and balls in boxes problems
Grid routes are choices of when to go right and when to go up. Many other problems, sharing sweets into boxes or climbing stairs, reduce to a similar count.
Key ideas
Routes on an m × n grid: C(m + n, m).
Via a point: routes to it × routes from it; avoiding a point: all − via it.
Rectangles in an m × n grid: C(m + 1, 2) × C(n + 1, 2).
Stairs with steps of 1 or 2: each count is the sum of the two before (Fibonacci).
n identical balls in k different boxes: C(n + k − 1, k − 1); no box empty: C(n − 1, k − 1).
A knockout tournament with n teams has n − 1 matches.
Watch out: Identical or different balls? The formulas are very different.
Practise this step
5 questions from this step only, in 8 minutes: new numbers and
stories every time, of exactly the types worked out below. Marked at the end, with every question
worked out.
14 types of question. Try each one yourself before you open
the hint or the solution.
Example 1 · level 7
In a league of 18 teams, every team plays every other team twice: once at home and once away. How many matches are played in the season?
Hint
Each team has a home match against every other team.
Worked solution
Home matches per team: 17
Matches: 18 × 17 = 306
Answer: 306 matches
Example 2 · level 7
104 players enter a knockout tournament: the loser of every match is out, some players may skip a round, and the last player left wins. How many matches are played?
Hint
Count the losers, not the rounds: every match puts out exactly one player.
Worked solution
Everyone but the winner loses once: 104 − 1 = 103 matches
Answer: 103 matches
Example 3 · level 8
Each half of a domino shows a number of spots from zero up to 3. A full set has every possible domino exactly once; a domino turned round is the same domino. How many dominoes are in the set?
Hint
There are 3 + 1 possible halves. Count the dominoes with two different halves and those with two equal ones.
Worked solution
Halves: 3 + 1 = 4
Different halves: C(4, 2) = 6; equal halves: 4
Set: 6 + 4 = 10
Answer: 10 dominoes
Example 4 · level 8
A town's streets form a grid. Home is at one corner and school is 3 blocks east and 3 blocks north of it. A shop is 2 blocks east and 2 blocks north of home. How many shortest routes from home to school go past the shop?
Hint
Count the shortest routes from home to the shop and from the shop to school, then multiply. A route of p blocks east and q north can be ordered in C(p + q, p) ways.
Worked solution
Home to shop: C(2 + 2, 2) = 6
Shop to school: 1 east, 1 north: C(1 + 1, 1) = 2
Routes: 6 × 2 = 12
Answer: 12 routes
Example 5 · level 9
In how many ways can 12 identical balls be put into 5 different boxes, if a box may stay empty?
Hint
Line up the 12 balls with 4 dividers between the boxes.
Worked solution
12 balls and 4 dividers make 16 places.
Choose where the dividers go: C(16, 4) = 1820
Answer: 1820 ways
Example 6 · level 9
29 couples meet at a party. Everyone shakes hands once with everyone else, except their own partner. How many handshakes are there?
Hint
Count the handshakes as if everybody shook everybody's hand, then take away the partners.
Worked solution
People: 2 × 29 = 58; all pairs: 58 × 57/2 = 1653
Without the couples: 1653 − 29 = 1624
Answer: 1624 handshakes
Example 7 · level 9
A chocolate bar is a grid of 2 by 4 squares. How many rectangles, of any size, can be cut out along the grid lines?
Hint
A rectangle is fixed by choosing two of the vertical grid lines and two of the horizontal ones.
Worked solution
Vertical lines: 3, choose 2: 3
Horizontal lines: 5, choose 2: 10
Rectangles: 3 × 10 = 30
Answer: 30 rectangles
Example 8 · level 9
A town's streets form a grid. A courier goes from one corner to the point 5 blocks east and 3 blocks north, always by a shortest route. The crossing 1 block east and 1 block north of the start is closed. How many shortest routes avoid it?
Hint
Count all shortest routes, then take away those through the closed crossing.
Worked solution
All: C(5 + 3, 5) = 56
Through the crossing: C(1 + 1, 1) × C(5 − 1 + 3 − 1, 5 − 1) = 30
Avoiding it: 56 − 30 = 26
Answer: 26 routes
Example 9 · level 9
6 identical rooks are placed on a square board with 7 squares along each side, so that no two are in the same row or column. In how many ways can this be done?
Hint
Choose the rows, choose the columns, then match the rows to the columns.
Worked solution
Rows: C(7, 6) = 7; columns: 7
Matching rows to columns: 6! = 720
Ways: 7 × 7 × 720 = 35,280
Answer: 35,280 ways
Example 10 · level 9
A board is a grid of 2 by 6 small squares. How many squares of any size can be found on it, along the grid lines?
Hint
A square of side k fits in (a − k + 1)(b − k + 1) places; add over every k.
Worked solution
Side 1: 2 × 6 = 12; side 2: (2 − 1) × (6 − 1) = 5; …
Up to side 2: in total 17
Answer: 17 squares
Example 11 · level 9
A staircase has 12 steps. You climb it 1 or 2 steps at a time. In how many different ways can you reach the top?
Hint
Your last move is either one step or two, so the ways to reach a step add up from the two steps below it.
In how many ways can 13 identical balls be put into 5 different boxes, if no box may stay empty?
Hint
Line up the balls; the 12 gaps between them are where the boxes can be split.
Worked solution
Choose 4 of the 12 gaps: C(12, 4) = 495
Answer: 495 ways
Example 13 · level 10
A grid has 8 by 9 squares. How many shortest routes along the grid lines lead from one corner to the opposite corner?
Hint
Every shortest route is 8 steps one way and 9 steps the other, in some order.
Worked solution
Choose which 8 of the 17 steps go the first way: C(17, 8) = 24,310
Answer: 24,310 routes
Example 14 · level 10
A climbing frame is a block of 5 by 1 by 3 cubes made of bars. A spider goes along the bars from one corner to the opposite corner by a shortest way. How many shortest ways are there?
Hint
Every shortest way is a word of 5 steps one way, 1 another and 3 up, in some order.
Worked solution
Steps: 5 + 1 + 3 = 9
Orders: 9!/(5! × 1! × 3!) = 504
Answer: 504 ways
Ready for the quiz?
Check yourself on this step: 5 questions, 8 minutes.