Math Core

Module 2.3 · Counting and Probability

Recursive counting

Some counts have no neat closed formula, but each case is built from smaller cases in a predictable way. Instead of counting size 1212 directly, you find how size nn depends on sizes n−1n - 1, n−2n - 2, and so on, then fill in a short table. On the AIME the numbers stay small enough to compute by hand.

Condition on the last step

The standard move is to look at how an object ends. Split the objects of size nn by their last piece, and notice that removing that piece leaves a smaller object of the same kind.

For example, let ana_n be the number of ways to climb nn stairs taking 11 or 22 steps at a time. The last move is either a 11-step (after which n−1n - 1 stairs were climbed in any valid way) or a 22-step (after n−2n - 2 stairs). So

an=an−1+an−2,a0=1, a1=1.a_n = a_{n-1} + a_{n-2}, \qquad a_0 = 1, \ a_1 = 1.

That gives 1,1,2,3,5,8,13,21,34,55,89,…1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, \dots, the Fibonacci numbers.

Building a recursion

  1. Define ana_n precisely, including what a0a_0 means (usually 11: the empty object).
  2. Split the objects of size nn into cases by their last piece (or first piece).
  3. Show that each case is in bijection with objects of a smaller size.
  4. Compute the first few terms by hand to check, then run the table up to nn.

When one sequence isn't enough

Sometimes the last piece alone doesn't tell you whether you can extend. Then track several sequences, one for each possible ending. For strings of AA, BB, CC with no ABAB anywhere, what you may append depends on whether the string ends in AA. Let xnx_n count valid strings ending in AA and yny_n those ending in BB or CC:

xn+1=xn+yn,yn+1=xn+2yn.x_{n+1} = x_n + y_n, \qquad y_{n+1} = x_n + 2y_n.

(After an AA you may add AA or CC; after BB or CC you may add anything.)

This "state" bookkeeping is the same idea you'll use for probability with states later in this unit.

Tilings

Tiling a strip with pieces of lengths 11 and 22 is the stair problem again. Wider boards need more care. For 3×n3 \times n boards and dominoes, look at how the left edge can be covered. For even nn the count tnt_n satisfies

tn=4tn−2−tn−4,t0=1, t2=3,t_n = 4t_{n-2} - t_{n-4}, \qquad t_0 = 1, \ t_2 = 3,

giving 1,3,11,41,153,571,…1, 3, 11, 41, 153, 571, \dots (and tn=0t_n = 0 for odd nn, since 3n3n squares can't be split into dominoes).

Common mistake

Check the first two or three terms by listing objects directly. Most wrong recursions give the right shape with the wrong starting values, and one wrong initial value ruins every later term.

Worked example: Stairs

In how many ways can you climb 1010 stairs taking 11 or 22 steps at a time?

Continue the Fibonacci table from a0=a1=1a_0 = a_1 = 1: 1,1,2,3,5,8,13,21,34,55,891, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89. The answer is a10=89a_{10} = 89.

Worked example: No three 1s in a row

How many binary strings of length 1010 contain no three consecutive 11s?

A valid string ends in 00, 0101, or 011011, and removing that ending leaves any valid shorter string. So an=an−1+an−2+an−3a_n = a_{n-1} + a_{n-2} + a_{n-3} with a0=1a_0 = 1, a1=2a_1 = 2, a2=4a_2 = 4:

1,2,4,7,13,24,44,81,149,274,504.1, 2, 4, 7, 13, 24, 44, 81, 149, 274, 504.

The answer is a10=504a_{10} = 504.

Worked example: A 3 by 6 board

In how many ways can a 3×63 \times 6 board be tiled by 1×21 \times 2 dominoes?

Let tnt_n count tilings of 3×n3 \times n and unu_n count tilings of a 3×n3 \times n board with one corner square removed. Covering the left column of a full board: either three horizontal dominoes stack there (leaving a 3×(n−2)3 \times (n - 2) board), or a vertical domino covers two of the three squares and a horizontal one covers the third (two mirror-image ways, each leaving a board with a corner removed). So tn=tn−2+2un−1t_n = t_{n-2} + 2u_{n-1}. Similarly un=tn−1+un−2u_n = t_{n-1} + u_{n-2}.

Starting from t0=1t_0 = 1, u1=1u_1 = 1: t2=1+2=3t_2 = 1 + 2 = 3, u3=3+1=4u_3 = 3 + 1 = 4, t4=3+8=11t_4 = 3 + 8 = 11, u5=11+4=15u_5 = 11 + 4 = 15, t6=11+30=41t_6 = 11 + 30 = 41.

Tip

For "remainder when divided by 10001000" questions with big recursions, keep only the last three digits at every step. The recursion still works modulo 10001000.

Practice

Practice 1

A child climbs a staircase of 1212 steps, taking 11, 22, or 33 steps at a time. In how many ways can the child reach the top?

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 2

How many subsets of {1,2,3,…,12}\{1, 2, 3, \dots, 12\}, including the empty set, contain no two consecutive integers?

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 3

A fair coin is flipped 88 times. The probability that the sequence of flips never contains three heads in a row is mn\dfrac{m}{n} in lowest terms. Find m+nm + n.

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 4

A 1×81 \times 8 strip is to be covered, without overlap, by red 1×11 \times 1 tiles, blue 1×11 \times 1 tiles, and green 1×21 \times 2 tiles. Tiles of the same color are identical. How many coverings are there?

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 5

In how many ways can a 3×103 \times 10 board be tiled by 1×21 \times 2 dominoes?

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 6

How many strings of length 77 using the digits 00, 11, 22 have the property that any two adjacent digits differ by at most 11?

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 7

How many strings of length 77 using the letters AA, BB, CC do not contain ABAB as two consecutive letters?

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Practice 8

A frog climbs a ladder with 2020 rungs, starting on the ground and moving up 11, 22, or 33 rungs per jump, and it must land exactly on the top rung. Let NN be the number of different jump sequences. Find the remainder when NN is divided by 10001000.

Enter a number. Fractions like 3/4 and sqrt(2) are OK.

Real contest practice