Solution:
One way is to walk directly from room 10 to 20. Else, divide the rooms into 10 pairs A0=(10,20),A1=(1,11),A2=(2,12),…,A9=(9,19). Notice that
- each move is either between rooms in Ai and A(i+1)mod10 for some i∈{0,1,…,9}, or between rooms in the same pair, meaning that our path must pass through A0,A1,…,A9 in that order before coming back to room 20 in A0,
- in each of the pairs A1,A2,…,A8, we can choose to walk between rooms in that pair 0 or 1 times, and
- we have to walk between rooms 9 and 19 if and only if we first reach A9 at room 9 (so the choice of walking between A9 is completely determined by previous choices).
Thus, the number of ways to walk from room 10 to 20 is 1+28=257.