Hello Community!
Can anybody help me with the problem I am posting above as an image link? This is ZIO 2014 P3.
I have tried this problem and the real difficulty of it seems to be that instead of just finding the number of valid codes, you have been constrained with the number of digits. So there are $3$ choices for the second digit, the first digit being $2$ but once we actually go there, we realize that numbers $1$ and $3$ have just two choices but $5$ has only one choice. It may be manageable to do to some extent but actually with $8$ digits and later on, $10$ and $13$ may provide to be a difficult task.
I would appreciate any help.
Thanks.
HINT ONLY (since this looks like homework / contest problem)
One way to solve this is to set up a recurrence where $f(a,n) =$ number of codes starting with $a$ and of total length $n$. Can you write $f(a,n)$ in terms of other $f()$ values of smaller $n$?
(Further optimization: instead of $a=1,2,\dots,9$ you can reduce the space by symmetry.)