AZTest
Counting study guide · step 4 of 5

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

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.

Start the 5-question quiz

Every question type in this step, 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
= 306
n(n−1)
  1. Home matches per team: 17
  2. 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?

N = 104?
Hint

Count the losers, not the rounds: every match puts out exactly one player.

Worked solution
N = 104= 103
N−1
  1. 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?

000112…n = 3?
Hint

There are 3 + 1 possible halves. Count the dominoes with two different halves and those with two equal ones.

Worked solution
000112…n = 3= 10
C(n+1,2)+(n+1)
  1. Halves: 3 + 1 = 4
  2. Different halves: C(4, 2) = 6; equal halves: 4
  3. 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
= 12
C(c+d,c)×C(a−c+b−d,a−c)
  1. Home to shop: C(2 + 2, 2) = 6
  2. Shop to school: 1 east, 1 north: C(1 + 1, 1) = 2
  3. 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
  1. 12 balls and 4 dividers make 16 places.
  2. 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
= 1624
C(2n,2)−n
  1. People: 2 × 29 = 58; all pairs: 58 × 57/2 = 1653
  2. 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?

a = 2b = 4?
Hint

A rectangle is fixed by choosing two of the vertical grid lines and two of the horizontal ones.

Worked solution
a = 2b = 4= 30
C(a+1,2)×C(b+1,2)
  1. Vertical lines: 3, choose 2: 3
  2. Horizontal lines: 5, choose 2: 10
  3. 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
= 26
C(a+b,a)−C(c+d,c)·C(a−c+b−d,a−c)
  1. All: C(5 + 3, 5) = 56
  2. Through the crossing: C(1 + 1, 1) × C(5 − 1 + 3 − 1, 5 − 1) = 30
  3. 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?

n = 7?
Hint

Choose the rows, choose the columns, then match the rows to the columns.

Worked solution
n = 7= 35,280
C(n,k)2×k!
  1. Rows: C(7, 6) = 7; columns: 7
  2. Matching rows to columns: 6! = 720
  3. 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?

b = 6a = 2?
Hint

A square of side k fits in (a − k + 1)(b − k + 1) places; add over every k.

Worked solution
b = 6a = 2= 17
∑k=1a(a−k+1)(b−k+1)
  1. Side 1: 2 × 6 = 12; side 2: (2 − 1) × (6 − 1) = 5; …
  2. 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.

Worked solution
  1. Ways to reach step 1, 2, 3, …: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233
  2. Step 12: 233

Answer: 233 ways

Example 12 · level 10

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
  1. 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
  1. 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?

a = 5b = 1c = 3?
Hint

Every shortest way is a word of 5 steps one way, 1 another and 3 up, in some order.

Worked solution
a = 5b = 1c = 3= 504
(a+b+c)!a!·b!·c!
  1. Steps: 5 + 1 + 3 = 9
  2. Orders: 9!/(5! × 1! × 3!) = 504

Answer: 504 ways

Ready for the quiz?

Check yourself on this step: 5 questions, 8 minutes.

Start the quiz

All steps of the Counting study guide

  1. The multiplication principle

    Outfits, routes through towns, number plates, PINs, menus and numbers made from digits.

  2. Arrangements (permutations)

    Photos with people at the ends, podiums, groups that stay together, round tables and books by subject.

  3. Choosing (combinations)

    Committees, teams from two groups, lines and triangles through points, lottery and handshakes.

  4. Paths, grids and sharing out

    Routes on a grid, via a shop or avoiding a crossing, tournaments, dominoes, rectangles in grids, stairs and boxes.

  5. Complements and overlaps

    Neither club, divisible by neither, three sports, repeated digits, passwords and the pigeonhole principle.

When every step feels easy, take the whole Counting test: 10 questions in 15 minutes.