Problem 2.23 Easy Free 3 variations

Climbing Stairs One or Two at a Time

A rabbit stands at the bottom of a staircase with 1010 steps. At each move it hops up either 11 or 22 steps. Find the number of distinct sequences of hops that take the rabbit from the ground to the top step.

Work it out, then compare with the answer.

SolutionShow the worked solution

Let f(n)f(n) be the number of hop sequences reaching step nn, with f(0)=1f(0)=1 for the empty sequence. Condition on the last hop. If it is a 11, the earlier hops form any sequence reaching step n−1n-1. If it is a 22, they form any sequence reaching step n−2n-2. These cases are disjoint and exhaustive, so

f(n)=f(n−1)+f(n−2)(n≥2),f(0)=f(1)=1.f(n)=f(n-1)+f(n-2)\qquad(n\ge 2),\qquad f(0)=f(1)=1 .

Iterating gives 1,1,2,3,5,8,13,21,34,55,891,1,2,3,5,8,13,21,34,55,89 for n=0,…,10n=0,\dots,10. Hence f(n)=Fn+1f(n)=F_{n+1}, where F1=F2=1F_1=F_2=1 are the Fibonacci numbers, and f(10)=F11f(10)=F_{11}.

89\boxed{89}

Key idea. Conditioning on the final move turns the count into the Fibonacci recursion.

Variations

The same idea with a twist. Each solution gives only the changed step.

Variation 2.23a

A rabbit stands at the bottom of a staircase with 1010 steps. At each move it hops up some number of steps strictly greater than 11 (so a single hop of 11 step is never allowed). Find the number of distinct sequences of hops that take the rabbit from the ground to the top step.

Work it out, then compare with the answer.

Solution

Let h(n)h(n) count the hop sequences reaching step nn with every hop at least 22. Set h(0)=1h(0)=1 and h(1)=0h(1)=0. Condition on the last hop.

  • If it equals 22, removing it leaves any valid sequence for step n−2n-2: h(n−2)h(n-2) ways.
  • If it is at least 33, shorten it by 11. This gives a bijection with the valid sequences for step n−1n-1, since a last hop of at least 33 becomes a last hop of at least 22: h(n−1)h(n-1) ways.

Hence h(n)=h(n−1)+h(n−2)h(n)=h(n-1)+h(n-2) for n≥2n\ge 2. Starting from h(0)=1h(0)=1 and h(1)=0h(1)=0, the values are 1,0,1,1,2,3,5,8,13,21,341,0,1,1,2,3,5,8,13,21,34. So h(n)=Fn−1h(n)=F_{n-1} and

34\boxed{34}
Variation 2.23b

A rabbit stands at the bottom of a staircase with 1010 steps. At each move it hops up an odd number of steps. Find the number of distinct sequences of hops that take the rabbit from the ground to the top step.

Work it out, then compare with the answer.

Solution

Let o(n)o(n) count the sequences of odd hops reaching step nn. Clearly o(1)=o(2)=1o(1)=o(2)=1. For n≥3n\ge 3, condition on the last hop.

  • If it is 11, the earlier hops reach step n−1n-1: o(n−1)o(n-1) ways.
  • If it is at least 33, shorten it by 22. It stays odd and positive, which gives a bijection with the odd-hop sequences for step n−2n-2: o(n−2)o(n-2) ways.

Thus o(n)=o(n−1)+o(n−2)o(n)=o(n-1)+o(n-2). With o(1)=o(2)=1o(1)=o(2)=1 this is the Fibonacci sequence, so o(n)=Fno(n)=F_n and

55\boxed{55}
Variation 2.23c

A fair coin is tossed 1010 times. Find the probability that every run of tails in the resulting sequence has length exactly 22 (so tails only ever occur in consecutive pairs, never alone and never three or more in a row). For instance, with 44 tosses, TTHHTTHH, TTTTTTTT, and HHHHHHHH satisfy this, while HTHHHTHH and TTTHTTTH do not.

Work it out, then compare with the answer.

Solution

Interpretation. The example counts TTTTTTTT as valid. So the condition means that tails come in consecutive pairs: each run of tails has even length. Equivalently, the sequence is a tiling of the 1010 tosses by blocks HH and TTTT.

Count. Let t(n)t(n) be the number of such strings of length nn. A valid string ends in HH or in TTTT, and removing that block leaves a valid string of length n−1n-1 or n−2n-2. Hence t(n)=t(n−1)+t(n−2)t(n)=t(n-1)+t(n-2) with t(1)=1t(1)=1 and t(2)=2t(2)=2. This is exactly the staircase count, so t(n)=Fn+1t(n)=F_{n+1} and t(10)=89t(10)=89.

Probability. All 2102^{10} outcomes are equally likely, so the probability is

891024≈0.087\boxed{\dfrac{89}{1024}\approx 0.087}

(If instead every run of tails must have length exactly 22, the TTTT blocks may not be adjacent. Then a(n)=a(n−1)+a(n−3)a(n)=a(n-1)+a(n-3), giving 41/102441/1024.)