[Question]
  [
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!
  
[Answer]
# [Python 2](https://docs.python.org/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<1::2]in"123456789")
```
[Try it online!](https://tio.run/##K6gsycjPM/qfZhvzPycxNyklUaHCKl2jQsdQswZEGWhypdvCJHQSrXJS8zSKU0s0KqITrayMYjU1bW1BbBtDEC8zT8nQyNjE1MzcwlJJ839BUWZeiUKahpKJhamFmQVQBAA "Python 2 – Try It Online")
---
# [Python 3](https://docs.python.org/3/), ~~82~~ ~~79~~ ~~78~~ 77 bytes
```
lambda x:g(x,1)|g(x,0)
g=lambda x,a:len({*x[a::2]})==(x[a<1::2]in"123456789")
```
[Try it online!](https://tio.run/##K6gsycjPM/6fZhvzPycxNyklUaHCKl2jQsdQswZEGWhypdvCJHQSrXJS8zSqtSqiE62sjGJrNW1tNYBsG0MQLzNPydDI2MTUzNzCUknzf0FRZl6JRpqGkomFqYWZhZKm5n8A "Python 3 – 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.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~13~~ 11 bytes
```
Ds2ZI’M¦Ẏ¬Ạ
```
[Try it online!](https://tio.run/##AS8A0P9qZWxsef//RHMyWknigJlNwqbhuo7CrOG6oP///zE4MjgzODQ4NTg2ODc4ODg5OA "Jelly – Try It Online")
Explanation:
```
Ds2ZI’M¦Ẏ¬Ạ Accepts an integer
D           Get individual digits
  2         2
 s          Split into chunks of specific length
   Z        Zip
    I       Take deltas
     ’      Decrement
      M     Take maximal indices
       ¦    Apply at specific indices
        Ẏ   Reduce dimensionality
         ¬  Vectorized NOT
          Ạ Check if all are truthy
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 15 bytes
```
TG9LNýN.øŒ})˜Iå
```
[Try it online!](https://tio.run/##MzBNTDJM/f8/xN3Sx@/wXj@9wzuOTqrVPD3H8/DS//8NLYwsjC1MLEwtzCzMLSwsLC0A "05AB1E – Try It Online")
### Explanation
```
TG9LNýN.øŒ})˜Iå
TG        }     # For 1 to 9...
  9L             # Push [1 .. 9]
    Ný           # Join with current value 
      N.ø        # surround with current value
         Œ       # Push substrings
           )    # Wrap stack to array
            ˜   # Deep flatten the array
             I  # Push input
              å # Is the input in the array?
                # Implicit print
```
It should work (test cases did) but if you find any flaws please let me know.
14 Bytes if no output counts as falsy:
```
TG9LNýN.øŒIåi1
```
[Answer]
## D, 117 bytes
```
int f(string n){int o=n[0]!=n[2],x=n[o];foreach(i,c;n){if(i%2!=o&&i>1&&c!=n[i-2]+1||i%2==o&&c!=x)return 0;}return 1;}
```
Definitely suboptimal, but it works fine
[Try It Online!](https://tio.run/##NVDtboMwDPzPU7iRQKCxCZIQ3EZsD4L4UfHRRaLJBGzr1PLsLIFiKfGdfU4uaZZFXb/MMME4NW92KSM9T@kJunCcBqUvoKO746bQZVId7E6r@GaTqWRnhvZcf4YqrqWTdaHy6aEwQaDe0yConVq90uolfTxsp3AdW7xFQzt9DxoSOT9RKmfP@zGqgetZ6TCCuwc2NgtlBT0UUJIUKTLkmKHAHBGPSGIgnHHu8lp2IKWUMsppRsVGGc8cEDnlScoEWxkTyCnP0SqRiX1uG1zZftlRkEqudp7vhVBL6HePLn4HNbVdr0PijyfwRzuvY/uFOoIPIH/tSOAERBsSbQfN3rws/w)
[Answer]
# Haskell, ~~108~~ ~~113~~ ~~97~~ 95 bytes
```
d(x:_:r)=x:d r
d r=r
c(x:n:r)=and$all(==x)(d r):zipWith(==)(d$n:r)[n..]
f s@(_:n:_)=c s||c(n:s)
```
Sample call: `f "182838485868788898"` yields `True`
Ungolfed version with explanations:
```
-- Take every other element from the string, starting with the first
d (x:_:r) = x : d r
d r       = r
c (x:n:r) = and $ all (== x) (d r)              -- Every other char is equal to the first
                : zipWith (==) (d $ n:r) [n..]  -- The remaining chars are a prefix of n(n+1)(n+2)...
f s@(_:n:_) = c s      -- The case where s already starts with x
           || c (n:s)  -- If not, prepend a dummy x and try again
```
[Answer]
## JavaScript (ES6), ~~66~~ ~~63~~ 60 bytes
Takes input as a string.
```
s=>[...s].every((d,i)=>d-s[j^(k=i+j&1)]==k*i>>1,j=s[2]-s[0])
```
### Test cases
```
let f =
s=>[...s].every((d,i)=>d-s[j^(k=i+j&1)]==k*i>>1,j=s[2]-s[0])
console.log('[Truthy]');
console.log(f("182838485868788898"))
console.log(f("4344"))
console.log(f("85868"))
console.log(f("12223242526"))
console.log('[Falsy]');
console.log(f("12345"))
console.log(f("6724013635"))
console.log(f("36842478324836"))
console.log(f("1222232425"))
```
[Answer]
# C (gcc), 123 bytes
```
#define X*s&&*s++-++n&&(r=0)
t,n,x,r;f(char*s){t=*s==s[2];for(r=1,n=s[t],x=s[!t],s+=2;*s;)t||X,*s&&*s++-x&&(r=0),t&&X;n=r;}
```
[Try it online!](https://tio.run/##fY5LbsMwDET3PoXqooL1CRBTssxC0D0MtFkETpx6USWQtDCQ5Oyu4H5WjbkZkvMwZL859f08Px@Ow@iPpOORUh6F2AjhKa2C27IiSS8nGexQ9R/7wCO7Jsejc/ENdnY4h0zV0ucx7eSU5SlrFA4sj5al262Tf6nTT6ZMlHbWu2Dv8@gT@dyPvmLFtSC5LiGvhqp8Obz7UpLc1QioUGODBltEfMWSMfsA1krrFXsJWfFrAFCgoQGzUA8xpZuVGNOC3tbKqDVIGdSgW8z3UJl/wIyR36e@v1qg@/wF)
[Answer]
# [Python 3](https://docs.python.org/3/), ~~99 96~~ 89 bytes
* Saved 3 bytes: use of `all()` function
* @WheatWizard saved 7 bytes:shorthanding `&` `|` and replace extra variable by `k<1`
```
lambda x,g=lambda x,k:(x[k<1::2]in'123456789')&all(j==x[k]for j in x[k::2]):g(x,0)|g(x,1)
```
[Try it online!](https://tio.run/##ZY7LCoNADEX3/QpxUWfAhZPEMQ6dL2ldWIrWR1XEhYX@ux1bEGxXSc69HDI8p3vf4VLYy9Lmj@st9@awtNvaGDGfm5MyBrKqCxQgxTrhNJDHvG1Fba2Ls6IfvdqrOs8da1OaUsxhJF/rUHIZxqqbRCF8xcDIxDFrTpg5ZV/KwxYTEu3Ap7gjCgAQCGLQP9x9tiM6AYoUatxj1ExACTsJo/5zf@UOL28 "Python 3 – Try It Online")
Explanation:
First split the string into two lists: one with odd-indexed and other with even-indexed elements. The two lists A and B are supposed be such that either:
1. A contains same number and B contains consecutive numbers in ascending order.
OR just the opposite
2. B contains same number and A contains consecutive numbers in ascending order.
The consecutive condition is checked by: `a in '123456789'`
The same-number condition is checked by: `all(i=a[x] for i in a)` 
[Answer]
# [PHP](https://php.net/), 68 bytes
```
for(;$v<10;)$s.=strstr(+$v.join(+$v,range(1,9)).+$v++,$argn);echo$s;
```
[Try it online!](https://tio.run/##HYxBDoMgFAX3HsP8BQRCpLb6zNd4FtOotAsg0Hh9qiazmNlMdLGMc3SxoiXtfqotHmjxxAsdegADai5bSILpGG3DkrKZ8i@dCEWH@YaPv0Snxe@rsHqQ0pytlL6Pkte3C5S5lD8 "PHP – Try It Online")
Output part of search string starting from and including the first occurrence of input to the end of search string as truthy value and nothing for falsy
for 2 Bytes more you can replace `echo$s;` with `!!echo$s;` to get `1` as truthy value
Find the occurrence of the input in one of the following strings in the array
```
Array
(
    [0] => 0102030405060708090
    [1] => 1112131415161718191
    [2] => 2122232425262728292
    [3] => 3132333435363738393
    [4] => 4142434445464748494
    [5] => 5152535455565758595
    [6] => 6162636465666768696
    [7] => 7172737475767778797
    [8] => 8182838485868788898
    [9] => 9192939495969798999
)
```
[Answer]
# [MATL](https://github.com/lmendo/MATL), 15 bytes
```
2L&),duw]hSFTX=
```
[Try it online!](https://tio.run/##LYurDsJQEEQ9H8JNE0R39nGnoo6g6qioIYEEgQAH4fMvS0GdnMmcx@V5b@eGadvtrq/36XY8zMvYlv3cihBUGp3BSnJg2RRTs8Q6JgWAwuCI1dQ8GRXWi4Z@RYMGq8wbNf7NL0px@uDSu0j5AA "MATL – Try It Online")
With some help of @LuisMendo in chat. Note that, if empty output + error is also considered 'falsy', the `X` can be left out, bringing the score to **14 bytes**.
```
2L&)     % Split the input into odd and even-indexed elements
    ,   ] % Do twice (new feature since MATL v20.0), i.e., on both halves of the input
     d     % Pairwise differences of the array. Results in [0,0,...] for the 'constant' part,
            %  and [1,1,...] for the 'increasing' part.
      u      % Get unique elements. Results in [0] for the constant part, [1] for the increasing part.
       w      % Swap the stack to do the same for the other half of the input.
         hS    % Horizontal concatenation followed by sort. Results in [0,1] for the desired string.
           FTX= % Check if the result is indeed [0,1]. Implicit display.
```
[Answer]
## JavaScript (ES6), 54 bytes
```
f=
s=>[...s].every((e,i)=>i<2|e-s[i-2]==(s[2]!=s[0]^i%2))
```
```
<input oninput=o.textContent=this.value[3]?f(this.value):``><pre id=o>
```
Takes input as a string.
[Answer]
# [Julia](https://julialang.org), ~~57~~ 56 bytes
```
~s=(!x=occursin(s,join(x*k for k='0':'9')x);!s[1]|!s[2])
```
* replace `||` by `|` by @MarcMush
[Attempt This Online!](https://ato.pxeger.com/run?1=VVBLTsMwFFzjU7hhkQYFKX7-PYMicQBuUGURlURNG2IpdqQgIS7Cppveid4GOwEkNp43o_HMsz8vx6nv6vP1y4-TP7yVO5IwBOQoUKJCjYgGk5wkggsRcZHjwACAgwAJKlJdaKZBcy201EonOb2lzr421LbUH5ow95Pv7OBoW3c9tUNQO0cq0ta9W3uBCxmjlAZRMK74wrhCAUJj6EKufpvX6sgkSiNZIRmLzDADhhthpFnWrC6Tb-_xih-u3G7m0u730-i6Yevyow0w351oa0d6KtMifUhNms3Z48btWPUeTqiyn_vP0eRoF9ZePorcPNXONaOnIbgMWkOa4YWQP9vyrP-uKC22NfN8XvEb)
* input: the number as decimal string
[Answer]
# Mathematica, 121 bytes
```
(m[x_]:=Take[s=IntegerDigits@#,{x,Length@s,2}];w[b_,n_]:=Union@Differences@m@b=={1}&&Length@Union@m@n==1;w[1,2]||w[2,1])&
```
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 20 bytes
```
ASm.+sMd.Tcz2&-GZ-H1
```
Output `[]` when the number matches the digit pattern, anything else otherwise.
[Try it online!](https://pyth.herokuapp.com/?code=ASm.%2BsMd.Tcz2%26-GZ-H1&input=12223242526&debug=0)
**Explanations** (example with input `85868`)
```
ASm.+sMd.Tcz2&-GZ-H1
          cz2           # Chop the input in pairs: ['85', '86', '8']
        .T              # Transpose, ignore absences: ['888', '56']
     sM                 # Convert to integers: [[8, 8, 8], [5, 6]]
  m.+  d                # Compute deltas: [[0, 0], [1]]
 S                      # Sort: [[0, 0], [1]]
A                       # Assign first list to G and second list to H
              -GZ       # Filter 0 on G (on absence): [0, 0] -> []
                 -H1    # Filter 1 on H (on absence): [1] -> []
             &          # Check both lists are empty (logical and): [] & [] -> []
```
[Answer]
# Pyth, 17 bytes
```
qU2Ssm{.+d.TcjQT2
```
[Try it here](http://pyth.herokuapp.com/?code=qU2Ssm%7B.%2Bd.TcjQT2&test_suite=1&test_suite_input=182838485868788898%0A4344%0A85868%0A12223242526%0A12345%0A6724013635%0A36842478324836%0A1222232425%0A5859510511&debug=0)
Same algorithm as my Jelly answer.
Explanation:
```
qU2Ssm{.+d.TcjQT2 Accepts an integer
             jQT  Take digits of input
            c   2 Split in pairs
          .T      Transpose
     m            Map the following on each of the two resulting lists:
       .+d          Take deltas
      {             Deduplicate
    s             The list is now in [[a, b, ...], [A, B, ...]] format, convert it to [a, b, ..., A, B, ...]
   S              Sort
qU2               Check if equal to [0, 1]
```
[Answer]
# [Python 3](https://docs.python.org/3/), ~~167 161 157 131~~ 106 bytes
*-55 bytes thanks to @WheatWizard's suggestions*
```
def g(t):k,c,f,j=t[::2],t[1::2],'123456789',''.join;return(len({*k})and j(c)in f)or(len({*c})and j(k)in f)
```
[Try it online!](https://tio.run/##NclBDsIgFEXRrXQGmB9TiqWIcSWNA0OhAubTEBwY49qxsTp6N@8sz3JLKGqdrGtmWpiOYMBBOJdR6@4CZeTfJbwTh14O6kiAkH1IHk/ZlkdGerdIX7v4ZlecmkAN89g4lvIPzB/iBnXJHgudKRFSDEIRBmvzlrdbqV7J9WT1Aw "Python 3 – Try It Online")
[Answer]
# [Java (OpenJDK 8)](http://openjdk.java.net/), ~~128~~ ~~119~~ ~~118~~ ~~108~~ ~~107~~ 104 bytes
```
s->{int i=3,a=s[2]-s[0],b=s[3]-s[1];for(;++i<s.length;)a+=b-(b=s[i]-s[i-2]==a?a:2);return(a|b)==1&a!=b;}
```
[Try it online!](https://tio.run/##VVFRb4IwEH73V9xIXCACkbZgFeuy7HnJEh8NDwVB67CQtpgY5293gE5dk/buvvt6ve@64wfuVXUud@vvi9jXlTKwazG/MaL0i0ZmRlTS/1L5WmTc5PGgbtJSZJCVXGv45ELCaQBwQ7XhpjWHSqxh3@bspVFCblYJcLXRTk8FuFebZ1uuVskCCmAX7S1OQhoQDLuc6RVKPL0aJ27a@rjzgyQuKmXHo5GYa7/M5cZsY4ePWOrZHUl0JOGhhDH@xmfIiVVuGiVt/pM6jAWv/IWl8fkC/Yr7Vu79mVwbDezWIYAVUEQxJTSkEZ1QSqfUcv9yBBPyiHrKIwwQQhgRFKLoGcQkfITRBJFxgCP8hOGIEkQmtL1LcfS/3rXgAwtpOA2DcRgEVg@dr2ra8cBt5L2g2VWWc1e1PGqT7/2qMX7dskxhW0MPjfUMhnooLbfnu1D4nbW7wzfVR/tJ70rxo@04zvWh86Db58sv "Java (OpenJDK 8) – Try It Online")
# Explanation:
```
s->{                             // lambda
  int i=3,                       //  iterating index
      a=s[2]-s[0],               //  diff of even-indexed characters
      b=s[3]-s[1];               //  diff of odd-indexed characters
  for(;++i<s.length;)            //  iterate
    a+=b-(b=                     //   swap a and b
        s[i]-s[i-2]==a?a:2       //    or set b to 2 if the diffs don't match
      ));                        //
  return (a|b)==1                //  return true if both a and b are in (0,1)
        &a!=b;                   //         but different
}
```
[Answer]
# [Retina](https://github.com/m-ender/retina), 47 bytes
```
.
$*11;
(1+)(?<=\1;1+;\1)
^1+;1+
^;?(;1;)+;?$
```
[Try it online!](https://tio.run/##DcY7CoAwEAXAfs@RInFBfH6frJKLBMHCwsZCvP@aaua9vvs53VsJDWASoSnmbS8wqBUkkaMGWrUcDZbUcnBnR7DnwJETZy4k1x8 "Retina – Try It Online")
Outputs 1 if it matches the pattern, 0 if it does not
### Explanation
```
.
$*11;
```
Convert each digit n to n+1 in unary, separated by semicolons
```
(1+)(?<=\1;1+;\1)
```
(Trailing newline) converts each digit to the difference between itself and the one 2 spots before it
```
^1+;1+
```
(Trailing newline) removes the first 2 digits
```
^;?(;1;)+;?$
```
Counts the number of matches of this pattern, which checks for alternating 0s and 1s
[Answer]
# [Husk](https://github.com/barbuz/Husk), 19 bytes
```
S¤|o←Ẋ~&Λȯ¬→-E↔TC2d
```
[Try it online!](https://tio.run/##JcqtCgJBGEbhuzGNsN/vvJvFK9AmNoMgYhCbCBombBKxWY2C3bjJ5D04NzIuazscnuVuuyrrfDqWSXvfb3I6f1/NYfC5vZ/tI6fLcJzTdTriRSllRmAIFAZHBFAjqKiGfgRiZmFlY@9a1IJH1orExYI4lDWiAxDv7R8Hg9VGlRHNfw "Husk – Try It Online")
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 11 bytes
```
y"v¯vUfsk≈⁼
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyJBIiwiIiwieVwidsKvdlVmc2viiYjigbwiLCIiLCIxODI4Mzg0ODU4Njg3ODg4OThcbjQzNDRcbjg1ODY4XG4xMjIyMzI0MjUyNlxuMTIzNDVcbjY3MjQwMTM2MzVcbjM2ODQyNDc4MzI0ODM2XG4xMjIyMjMyNDI1XG41ODU5NTEwNTExIl0=)
]