Skip to content

Recursion: all problems

Focus mode: every practice problem from the chapter, one after another.

0 / 8 solved

Problem 10.5.1

AMC

Everyday at school, Jo climbs a flight of 6 stairs. Jo can take the stairs 1, 2, or 3 at a time. For example, Jo could climb 3, then 1, then 2. In how many ways can Jo climb the stairs?

6 stairs, jumps of 1, 2 or 3: f(6) = 24 ways

0123456top
f(3) = f(2) + f(1) + f(0) = 2 + 1 + 1 = 4

Jumps of 1, 2 or 3.

f(3) = f(2) + f(1) + f(0) = 2 + 1 + 1 = 4. Table filled up to stair 3.

Problem 10.5.2

AMC 10/12Challenge

This problem also appears in the book as 3.3.14.

Arjun and Beth play a game in which they take turns removing one brick or two adjacent bricks from one "wall" among a set of several walls of bricks, with gaps possibly creating new walls. The walls are one brick tall. For example, a set of walls of sizes 44 and 22 can be changed into any of the following by one move: (3,2)(3, 2), (2,1,2)(2, 1, 2), (4)(4), (4,1)(4, 1), (2,2)(2, 2), or (1,1,2)(1, 1, 2).

Arjun plays first, and the player who removes the last brick wins. For which starting configuration is there a strategy that guarantees a win for Beth?

Click a choice or type its letter (A–E).

Problem 10.5.3(additional)

AIME

There are 210=10242^{10} = 1024 possible 10-letter strings in which each letter is either an A or a B. Find the number of such strings that do not have more than 3 adjacent letters that are identical.

A/B strings, at most 3 equal letters in a row. States f(n): ends in A; g(n): ends in B. For n = 6 there are 48 A/B strings.

n4

A/B strings, at most 3 equal letters in a row

f(4): ends in A · 7

  • BBBA
  • BBAA
  • BABA
  • BAAA
  • ABBA
  • ABAA
  • AABA

g(4): ends in B · 7

  • BBAB
  • BABB
  • BAAB
  • ABBB
  • ABAB
  • AABB
  • AAAB
f(4) = g(3) + g(2) + g(1) = 4 + 2 + 1 = 7g(4) = f(3) + f(2) + f(1) = 4 + 2 + 1 = 7total for n = 4: f(4) + g(4) = 14

Dashed columns are base cases, counted by hand. Outlined cells feed the selected column.

A/B strings, at most 3 equal letters in a row. f(4) = g(3) + g(2) + g(1) = 4 + 2 + 1 = 7. g(4) = f(3) + f(2) + f(1) = 4 + 2 + 1 = 7. total for n = 4: f(4) + g(4) = 14.

Problem 10.5.4(additional)

AMC 12

For each positive integer nn, let S(n)S(n) be the number of sequences of length nn consisting solely of the letters AA and BB, with no more than three AAs in a row and no more than three BBs in a row. What is the remainder when S(2015)S(2015) is divided by 12?

A/B strings, at most 3 equal letters in a row. States f(n): ends in A; g(n): ends in B. For n = 16 there are 2 A/B strings (mod 12).

mod12
n4

A/B strings, at most 3 equal letters in a row

f(4) = g(3) + g(2) + g(1) ≡ 4 + 2 + 1 ≡ 7g(4) = f(3) + f(2) + f(1) ≡ 4 + 2 + 1 ≡ 7total for n = 4: f(4) + g(4) ≡ 2 (mod 12)

Mod 12, the totals repeat every 52 columns.

Dashed columns are base cases, counted by hand. Outlined cells feed the selected column.

A/B strings, at most 3 equal letters in a row. f(4) = g(3) + g(2) + g(1) ≡ 4 + 2 + 1 ≡ 7. g(4) = f(3) + f(2) + f(1) ≡ 4 + 2 + 1 ≡ 7. total for n = 4: f(4) + g(4) ≡ 2 (mod 12).

Problem 10.5.5(additional)

AIME

Call a permutation a1,a2,…,ana_1, a_2, \ldots, a_n of the integers 1,2,…,n1, 2, \ldots, n quasi-increasing if ak≤ak+1+2a_k \le a_{k+1} + 2 for each 1≤k≤n−11 \le k \le n-1. For example, 5342153421 and 1425314253 are quasi-increasing permutations of the integers 1,2,3,4,51, 2, 3, 4, 5, but 4512345123 is not. Find the number of quasi-increasing permutations of the integers 1,2,…,71, 2, \ldots, 7.

permutations of 1 to 7 with each term at most the next term + 2, built by inserting the largest number into a legal arrangement of the smaller ones: T(7) = 486

First → last · where can 5 go?

1234
3 of 5 places are legal for 5.

1, 2, 3, 4. 3 of 5 places are legal for 5.

Problem 10.5.6(additional)

AIMEChallenge

The figure below shows a ring made of six small sections which you are to paint on a wall. You have four paint colors available and you will paint each of the six sections a solid color. Find the number of ways you can choose to paint the sections if no two adjacent sections can be painted with the same color.

Problem 10.5.7(additional)

AMC 12Challenge

Let △A0B0C0\triangle A_0B_0C_0 be a triangle whose angle measures are exactly 59.999∘59.999^\circ, 60∘60^\circ, and 60.001∘60.001^\circ. For each positive integer nn, define AnA_n to be the foot of the altitude from An−1A_{n-1} to line Bn−1Cn−1B_{n-1}C_{n-1}. Likewise, define BnB_n to be the foot of the altitude from Bn−1B_{n-1} to line An−1Cn−1A_{n-1}C_{n-1}, and CnC_n to be the foot of the altitude from Cn−1C_{n-1} to line An−1Bn−1A_{n-1}B_{n-1}. What is the least positive integer nn for which △AnBnCn\triangle A_nB_nC_n is obtuse?

Problem 10.5.8(additional)

AIMEChallenge

Find the number of permutations of 1,2,3,4,5,61, 2, 3, 4, 5, 6 such that for each kk with 1≤k≤51 \le k \le 5, at least one of the first kk terms of the permutation is greater than kk.

permutations of 1 to 6 where one of the first k terms is greater than k, counted as all permutations minus those whose first failure is at k: T(6) = 461

  • k=1: max 6 > 1 ✓
  • k=2: max 6 > 2 ✓
  • k=3: max 6 > 3 ✓
  • k=4: max 6 > 4 ✓
  • k=5: max 6 > 5 ✓
Every check passes: this permutation counts.

T(6) = 6! − (T(1)·5! + T(2)·4! + T(3)·3! + T(4)·2! + T(5)·1!) = 720 − 259 = ?

6, 5, 4, 3, 2, 1. Every check passes: this permutation counts.