I've been trying to think of how to optimize for counting through digits with skipping numbers that have neighboring matching digit pairs. And it doesn't have to necessarily be base 10.
For example, these number don't have neighboring digit matching pairs:
12, 202, 95036, 121317, 901983
And these all do:
11, 22, 110, 20220, 902244
Now I can think of a programmatic way of of doing this as I roll over a digits position I'd have the program check both left and right for the same digit and if it is the same then skip it.
But I feel as if there's a pattern in this that a formula can identify when this occurs. If that's so I would like to know what it is. I think it may be quite helpful.
I would like consideration for the formula to be compatible with octal, hexadecimal, and base 64.
For an $n$ digit number in base $10$, you have $9$ choices for the first digit because $0$ is not allowed. You then have $9$ choices for each successive digit because it has to not match the one you just used, so there are $9^n$ such numbers. For base $b$, the same logic says it is $(b-1)^n$
To identify such numbers in a computer you can use bit operations for bases which are a power of two. For example, for hex, you can take $n$, right shift by four bits, and do a bitwise XOR with the original number. Then look at each block of four bits to see if it is $0000$. If you find one, there are two matching hex digits in a row. For other power of two bases, you can modify the right shift appropriately. For base $10$, it might be easiest to convert the number to binary coded decimal and do the same. Once you are converting to decimal, you might just as well look through the digits as you produce them.