(a) Find a recurrence relation (with initial conditions) for the number of ways a robot can climb a flight of n stairs if at each step it can go up $1$ stair and land on either foot; or go up $2$ stairs and land on its left foot; or go up $3$ stairs and land on its right foot.
(b) Use your recurrence relation to find the number of ways the robot can climb a flight of 50 stairs.
(c) Repeat the question if additionally, the robot cannot land on its left foot twice in a row.
(d) Use your recurrence relation to find the number of ways the robot can climb a flight of 50 stairs.
$\require{enclose}$
a) Let's start with the initial conditions (base cases)
The subscripts on L and R indicate the distance traveled
$R_1$ means 1 stair with the right foot
$L_1$ means 1 stair with the left foot
$R_2$ means 2 stair with the right foot
$L_3$ means 3 stairs with the left foot
The robot has 3 cases for whether it goes 1 stair, 2 stairs or 3
Putting it altogether: $$a_n = 2a_{n-1} + a_{n-2} + a_{n-3}$$
Let's verify $a_3$ by counting all the cases going 3 stairs
$R_3$, $L_2L_1$, $L_2R_1$, $L_1L_2$, $R_1L_2$ ($5$ cases so far)
Plus $2^3=8$ combinations of $L_1$ and $R_1$ to go a total 3 stairs moving 1 stair at a time
$a_3=5+8$
$=13$
and using the recurrence relation & plugging in base cases gives the same answer
$a_3 = 2a_{3-1} + a_{3-2} + a_{3-3}$
$=2a_{2} + a_{1} + a_{0}$
$=2*5 + 2 + 1$
$=13$
b) Evaluating recurrence relations is tedious by hand, but in Wolfram Mathematica they are dead simple to input & evaluate
c) The restriction that it can't do 2 left feet in a row complicates it significantly. Any time a left move is made, we must follow it with a right foot move to avoid 2 left feet in a row
There are $6$ cases in the recurrence relation but we can combine the $2$ for $b_{n-3}$
Putting it together: $$b_n = b_{n-1} + b_{n-2} + 2b_{n-3} + b_{n-4} + b_{n-5}$$
Now counting the base cases also gets harder
I've left them in the order of smallest to largest when read left to right
d) Again, hard to by hand, but using Mathematica: