= Step number
A <step number> is a <positive integer> whose adjacent <decimal digits> differ by exactly $1$. For example, $3210$ and $101$ are <step numbers>, while $112$ is not: its first two <numerical digits> have difference zero. Repetition is allowed; only neighboring differences are constrained.
The <numerical digits> form a <walk> on the <path graph> $0-1-\cdots-9$, starting at a nonzero digit. From a last digit $d$, the possible extensions are $d-1,d+1$ within the range $0,\ldots,9$. At endpoints there is only one extension.
For <digit dynamic programming>, record the last digit and a <bit mask> encoding the <set> of digits already visited. Appending $d'$ updates the visited <set> by <set union> with $\{d'\}$. Here <pandigital> means that every <decimal digit> appears at least once; repetitions are allowed. Accept only final states whose visited <set> contains all ten <numerical digits>. This separates local adjacency from the global requirement to have seen every digit.
Back to article page