Does it match the digit pattern? Recently I had a Maths test and noticed that a certain number on the test matched an interesting pattern. The number (28384) matched a generic digit sequence that looks like this

(n)(x)(n+1)(x)(n+2)(x)(n+3) etc...


where n and x are single digit integers. The sequence can begin with either x or n and end with either x or n+y.

Your task is, given a multi digit positive integer, output a truthy or falsey value, depending on whether the input matches the pattern. The input will be between 4 and 18 digits long. You may take input as a string representation of the integer. The input will not begin with a 0 but can contain or end with 0s.

n+y will always be a single digit number (hence why the length limit is 18).

Test Cases

These should output a truthy value

182838485868788898
4344
85868
12223242526


And these should be falsey

12345
6724013635
36842478324836
1222232425
5859510511


As with all code golfs, shortest code wins! Good luck and may the odds, be ever in your favour!
Python 2, 84 81 80 79 bytes

-1 byte thanks to ovs



lambda x:g(x,1)|g(x,0)
g=lambda x,a:len(set(x[a::2]))==(x[a&lt;1::2]in"123456789")


Try it online!



Python 3, 82 79 78 77 bytes

lambda x:g(x,1)|g(x,0)
g=lambda x,a:len({*x[a::2]})==(x[a&lt;1::2]in"123456789")


Try it online!

Slightly shorter in Python 3, but I didn't think it deserved its own answer.



Explanation

We set up a function g that takes string and an index (either 1 or 0).  g then returns whether or not len(set(x[a::2])), that is the number of unique digits in every other position, is equal to (x[a==0::2]in"123456789"), whether or not the other digits are in ascending order.  If the digits are in ascending order this returns whether or not they are all the same, if not it will ask if the set is empty, which it cannot be, thus always returning false.