Permutation and Combination Puzzle - Spy Keypad Keypad
1 2 3
4 5 6
7 8 9

J. Bond has to break into the headquarters of an evil organization
and steal important documents. The documents are in a safe that
can only be opened by entering the correct code into the keypad,
which is a 3 × 3 grid as shown on the right.
Bond has been told that every two consecutive digits in the code will
always be adjacent keys on the keypad. For example, the digit 1 will
only be followed by a 2 or 4, the digit 5 will only be followed by a
2, 4, 6 or 8, and so on. So 3252 and 12369 are valid codes, but 1234
is not (3 is not adjacent to 4 on the keypad) and 55 is not (5 is not
adjacent to 5 on the keypad).
Bond also knows the ﬁrst digit of the code and the length of the code. From this, he
would like to compute the number of possible codes he has to try. For instance, if the
ﬁrst digit is 4 and the length of the code is 3, then there are 8 possible codes, namely
{412, 414, 452, 454, 456, 458, 474, 478}.
In each of the following cases, given the ﬁrst digit of the code and the number of digits
in the code, help Bond compute the total number of possible secret codes. 
(a) First digit 2, number of digits 8.
(b) First digit 5, number of digits 10.
(c) First digit 9, number of digits 13.

This was a real tough one that I simply cannot get through.
Help please?

If in doubt, try it out. There is a potentially lengthy but workable tabular kind of solution illustrated by the first problem - starting with $2$, the possibilities for a one number code can be represented as:
$ \begin{array}{ccc}
0 & 1 & 0 \\
0 & 0 & 0 \\
0 & 0 & 0 \end{array}$
Two digits gives
$ \begin{array}{ccc}
1 & 0 & 1 \\
0 & 1 & 0 \\
0 & 0 & 0 \end{array}$
Three digits gives
$ \begin{array}{ccc}
0 & 3 & 0 \\
2 & 0 & 2 \\
0 & 1 & 0 \end{array}$
Four digits
$ \begin{array}{ccc}
5 & 0 & 5 \\
0 & 8 & 0 \\
3 & 0 & 3 \end{array}$
Five digits
$ \begin{array}{ccc}
0 & 18 & 0 \\
16 & 0 & 16 \\
0 & 14 & 0 \end{array}$
Six digits
$ \begin{array}{ccc}
34 & 0 & 34 \\
0 & 64 & 0 \\
30 & 0 & 30 \end{array}$
etc - there are some obvious patterns here which could be proved by induction if there were more problems of the same kind to solve - and similar things will appear on investigation of the other two cases.
