Problem

Source:

Tags: number theory



To unlock his cell phone, Joao slides his finger horizontally or vertically across a numerical box, similar to the one represented in the figure, describing a $7$-digit code, without ever passing through the same digit twice. For example, to indicate the code $1452369$, Joao follows the path indicated in the figure. João forgot his code, but he remembers that it is divisible by $9$. How many codes are there under these conditions?