[Question]
  [
(This is my first code-golf question)
When I was a child, my dad and I invented a game where the license plate we see on cars can give certain points based on some rather simple rules:
X amount of the same letter or number give X-1 points, examples:
```
22 = 1 point
aa = 1 point
5555 = 3 points
```
The numbers must be next to eachother, so `3353` only gives 1 point, as the 5 breaks the sequence of 3's.
A sequence of X numbers in ascending or descending order, at a minimum of 3, give X points, examples:
```
123 = 3 points
9753 = 4 points
147 = 3 points
```
The point system only works for 1-digit-numbers, so `1919` doesn't give points, and `14710` only give 3, (147).
Sequences can be combined to make more points, examples:
```
1135 = 4 points (1 point for 11 and 3 points for 135)
34543 = 6 points (3 points for 345 and 3 points for 543)
```
You are however not allowed to chop a larger sequence into 2 smaller sequences for extra points: `1234 = 123, 234 (6 points)` is not allowed.
Your task is, given a sequence, to determine the number of points the license plate gives.
In Denmark, the license plates are structured like this: CC II III, where C is character and I is integer, and thus my example inputs will reflect this structure. If you wish, you may make the sequence fit your own structure, or, if you feel really adventurous, let the program analyze the structure of the license plate and thus have it work on any type of license plate around the world. Explicitly state the structure you decide to use in your answer though.
You may take the input in any way you please, either a string or an array seem to make most sense to me.
Test input | output:
```
AA 11 111 | 5
AB 15 436 | 3
OJ 82 645 | 0
UI 65 456 | 6
HH 45 670 | 5
YH 00 244 | 5
AJ 00 754 | 1
```
Due to the nature of choosing your own structure, or even covering all structures, I dont necessarily see how a winner can be explicitly determined. I suppose the winner will be the shortest bytes on the structure one has decided. (And don't take an input like C I C I C, just to make it easy for yourself)
EDIT:
Due to comments asking, I have a few extra pieces of information to share: A sequence of ascending or descending numbers refers to an arithmetic sequence, so X +/- a \* 0, X +/- a \* 1, ... X +/- a \* *n* etc. So 3-5-7 for example is 3 + 2 \* 0, 3 + 2 \* 1, 3 + 2 \* 2. The sequence does not, however, need to start from 0 nor end in 0.
MORE EDIT:
You may give the input in any way you please, you dont need to input spaces, dashes or any other thing that makes a license plate more readable. If you can save bytes by only accepting capital letters or something like that, you may do that aswell. The only requirement is that your program can take a string/array/anything containing both characters and numbers, and output the correct amount of points according to the rules stated.
  
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~25~~ ~~22~~ ~~20~~ 18 bytes
Accepts a string of lower-case alphabetic chars and numbers with no spaces.
```
Ç¥0Kγ€gXK>OIγ€g<OO
```
[Try it online!](https://tio.run/##MzBNTDJM/f//cPuhpQbe5zY/alqTHuFt5@8JYdr4@///n5loCQIA "05AB1E – Try It Online")
or as a [Test Suite](https://tio.run/##MzBNTDJM/V9TVvn/cPuhpQbe5zY/alqTHuFt518JYdr4@/@vVDq830rh8H4lnf@JiYYgwAXUZmpibMaVn2VhZGZiylWaaWZqYmrGlZEBJM0NuCozDAyMTEy4ErMMDMxNgXSmJQgAAA)
[Answer]
# [Husk](https://github.com/barbuz/Husk), ~~20~~ ~~16~~ 15 bytes
-1 byte thanks to @Zgarb
Takes input without spaces and in lower case.
```
ṁ??¬o→LεL←gẊ¤-c
```
[Try it online!](https://tio.run/##yygtzv6vkJtf/Kip8dC2/w93NtrbH1qT/6htks@5rT6P2iakP9zVdWiJbvL///8TEw1BgCsxydDUxNiMKz/LwsjMxJSrNNPM1MTUjCsjA0iaG3BVZhgYGJmYcCVmGRiYm5pwZSZaggAA "Husk – Try It Online")
### Explanation
```
           Ẋ      Map over all adjacent pairs
            ¤-c   get the difference of their codepoints
          g       Split into groups of equal elements
ṁ                 Map then sum
 ?       ←          If the head of the list is truthy (not 0)
  ?    ε              If the length of the list is 1
   ¬                    return 0
                       Else
    o→L                 return the length + 1
                     Else
        L             return the length
```
[Answer]
# [Python 3](https://docs.python.org/3/), ~~193~~ 85 bytes
-3 bytes thanks to [Lynn](https://codegolf.stackexchange.com/users/3852/lynn)
Takes input as a byte-string with lowercase letters as: `b'aa11111'`.
```
def f(s):
 d=l=L=p=0
 for c in s:C=0!=d==c-l;p+=(c==l)+C*L;L=3>>C;d=c-l;l=c
 return p
```
[Try it online!](https://tio.run/##TdDBboMwDAbgM3kKtxdgZVIoSehA7oXjkPYAUw80gKBCgAiV2qdnDmVSffzsP4o9Pudm6KNlKasaas/4CYMSO8xxRM6gHibQ0PZgkgz5DktE/dml4wE9jdj5h@wjT3OMzucsLddWh5rBVM33qYdxmTUg/DLHu7pFEdpyA5B@8JJrKEWkSKJNmkZIFfO3meF2OiohSfgm91ZJmiJRmzwbzo9CvL984zyWVsJNHo9TrFb5T7XFly0SQXJhzO5qAih6YxeedcIc2oP@b8/CnHFq@9mjATehDHUC2CPu1wC1C2OqaYY1gdYCMIy9Qu7P9871lz8 "Python 3 – Try It Online")
[Answer]
# Java 8, 195 bytes
```
a->{int r=a[0]==a[1]?1:0,i=3,j,p=a[2],x,y,z;for(;i<7;p=a[i++])for(r+=(x=a[i])==p?1:0,j=-4;++j<4;r+=j==0?0:i<6&&p+j==x&x+j==(y=a[i+1])?++i<6&&y+j==(z=a[i+1])?++i<6&&z+j==a[i+1]?5:4:3:0);return r;}
```
Can definitely be golfed some more by using another technique to check for sequences.
**Explanation:**
[Try it here.](https://tio.run/##dVPRbptAEHzPV6z8YB0CI7ABR2BiuVElJ1HSqlarpBYPV3xxoASj40iNLb7d3YPaMbTl4dDNzN7ODlxM3@hgk7E0Xv08hAnNc7inUbq/AIhSwfgzDRk8yG0NQEjCF8qXAVDFQ7C6wCUXVEQhPEAKPhzo4GovldynSyPwcTWDqekaWuSPtFjLEBgG2lYrtZ33vOHEiyZjT6KRqgaKRLjqk60EAsX3s7o29geWp6rxxPKQjX3fmBpuNHH6/UzF3ba/lS9S1seYgTJV1Zota3jXhXcSbrCp7VruyDUUjzNR8BS4Vx08OVZW/EhwrD/TvW2iFbxiNGQheJSu6wiaXGLMUC9ElOj3NJs0tAY3GN@a8SsQLBfXNGc5ppOyX2fyOc1fsIQo@@Yg2VOQ3mxmyqengV2H/E58MG1r5CAxahOfbi@HjmUjYbSJrzeObdmywmkT8znCY@PvHk9zwxha1j@a3xrG2JaE2SYeHy/HTk10ejx9H1no94yoqjpZAPmZW7HpH1PBy/@HB@57jjqT2gUTRFGOwTWFgB@MpSH7nFDBMO5jib5m4o6V5ORP/qBsm7FQsNUXlheJ6Ki/0aRgbT0NRUGTkzrVQ3LeTheba7waM84pNjpVLspcsFd9Uwg9Q4siSVtVoELPheXRiws9RDrOUBKAB8vGQCNpmakFDU66U/kt6dFXVd/d6vAb)
```
a->{                      // Method with character-array parameter and integer return-type
  int r=                  //  Result-integer
        a[0]==a[1]?       //   If the two letters are equal:
         1                //    Start this result-integer at 1
        :                 //   Else:
         0,               //    Start the result-integer at 0 instead
      i=3,j,              //  Index-integers
      p=a[2],x,y,z;       //  Temp integers
   for(;i<7;              //  Loop (1) from index 3 to 7 (exclusive)
       p=a[i++])          //    And after every iteration: Set `p` and raise `i` by 1
     for(r+=(x=a[i])==p?  //   If the current digit (now `x`) equals the previous `p`:
             1            //    Raise the result-integer by 1
            :             //   Else:
             0,           //    Keep the result-integer the same
         j=-4;++j<4;      //   Inner loop (2) from -3 to 3 (inclusive)
       r+=j==0?           //    If `j` is 0:
           0              //     Skip it, so keep the result-integer the same
          :i<6            //    Else-if `i` is not 6,
           &&p+j==x       //    and the previous digit `p` + `j` equals the current digit,
           &x+j==(y=a[i+1])?
                          //    and the current digit `x` + `j` equals the next digit `y`:
            ++            //     Raise index `i` by 1 first,
              i<6         //     and check if `i` is not 6 again,
              &&y+j==(z=a[i+1])?
                          //     and if the new current digit `y` + `j` equals the next digit `z`:
               ++         //      Raise index `i` by 1 first again,
                 i<6      //      and check if `i` is not 6 again,
                 &&z+j==a[i+1]?
                          //      and if the new current digit `z` + `j` equals the next digit:
                  5       //       Raise the result-integer by 5
                 :        //      Else:
                  4       //       Raise it by 4 instead
              :           //     Else:
               3          //      Raise it by 3 instead
           :              //    Else:
            0             //     Keep it the same
     );                   //   End of inner loop (2)
                          //  End of loop (1) (implicit / single-line body)
  return r;               //  Return the result-integer
}                         // End of method
```
[Answer]
# [R](https://www.r-project.org/), ~~153~~, ~~145~~, 143 bytes
```
function(x){p=0;s=sum;if(x[1]==x[2])p=1;a=diff(strtoi(x[3:7]));p=p+s(a==0);l=sort(table(a[a!=0]),T);(p=p+s(l[(l[((s(l)>0)&(l[1]>1))]+1)>2]+1))}
```
Anonymous function that takes a character vector and returns an integer.   
Expected input `z(c("A", "A", "1", "1", "1", "1", "1"))`
[Try it online!](https://tio.run/##bdDPS8MwFMDxu39FnSDvsR2S/ljV8Ap62nbx4g5ScojTQqGupc2gTPzba9@C2aaD8qV9@aSkbYdhT8Vuu7FlvYUevxoSqqNu96nKAvpcaqI@DzU2JJWh97IooLOtrctxMXpINaJqqJl2YIgEqoq6urVgzVv1ASY31yQ0zl5QgVNVzheMN5gJvB0fpM4kop5KzEIufg972MDkcTILXOTFIAY3QXJ1tE9@MeHEnIgzdzZy9plHK84dJ3Tid0PirHB2zaOlF8kJO7537uyCR4u/YkzKEWfnffVW@IR@a/z/21bnNj05zcFKZ5f@n91fzMHGww8 "R – Try It Online")
Ungolfed version
```
function(x){
  pnt <- 0; s <- sum
  if(x[1] == x[2]) pnt <- 1
  a <- diff(strtoi(x[3:7]))
  pnt <- pnt + s(a == 0)
  l <- sort(table(a[a!=0]), T)
  (pnt <- pnt + s(l[(l[((s(l) > 0) & (l[1] > 1))] + 1) > 2] + 1))
}
```
[Answer]
# [Perl 5](https://www.perl.org/) `-pF`, ~~116~~ 89 bytes
```
$a.=($_=(ord$F[++$t])-ord)?chr$_+77:++$;for@F[0..@F-2];$_=$a=~s/(\S)\1+/$;+=length$&/ge+$
```
[Try it online!](https://tio.run/##RY1RS8MwFIXf@ysuLOhmXZO0TSuW4OpDmYL4ID7oNiRucS2UtiQZUxj@dOtdJwgX7vnO5ZzbaVOL3tKlpXSb4T4EF5Rms0LSAA0YzVWzqbUFV2qomm7nQFnYWb1BGsyute4SjEJt0FANlO0eRWXBrk3VOdirxlmonDeCp5Oj1m6n6vrr7/Tfva9c2eK2nVpre42JPOdhFAuPGMkykkmiJHmX5@cZcXLwRkZb7eCjNdDoTwfOVKruiQrkmLzJcWs2pFj4PnGryRRhcrMuDXnz0/QazQxjs2LBgmBWTMNVhgl88G3pePk0WXKfksyXtW62riRndKt90vd5DpzjcDiA8PJb4ALiKEGKvMd7uAohiQUS857vIMGbON4Sbz5HCUnKhtzLHBiDMI5PLfdHSsWR@LETVRT@fXgFHkI0dA7EOIScDZ0nikSKFP@0navaxvbTBxEwzvpp3RW/ "Perl 5 – Try It Online")
[Answer]
# [Pyth](https://pyth.readthedocs.io), ~~51~~ 50 bytes (staggering)
```
+/|R0.+QZslM.MlZ+kfTsmm?&!-K.+sMkhK.AKkY.:>Q2d}3 5
```
**[Verify all test cases](https://pyth.herokuapp.com/?code=%2B%2F%7CR0.%2BQZslM.MlZ%2BkfTsmm%3F%26%21-K.%2BsMkhK.AKkY.%3A%3EQ2d%7D3+5&input=%22HH45670%22&test_suite=1&test_suite_input=%22AA11111%22%0A%22AB15436%22%0A%22OJ82645%22%0A%22UI65456%22%0A%22HH45670%22%0A%22YH00244%22%0A%22AJ00754%22&debug=0)** or **[Try it here.](https://pyth.herokuapp.com/?code=%2B%2F%7CR0.%2BQZslM.MlZ%2BkfTsmm%3F%26%21-K.%2BsMkhK.AKkY.%3A%3EQ2d%7D3+5&input=%22HH45670%22&test_suite_input=%22AA11111%22%0A%22AB15436%22%0A%22OJ82645%22%0A%22UI65456%22%0A%22HH45670%22%0A%22YH00244%22%0A%22AJ00754%22&debug=0)**
[Answer]
# [C (gcc)](https://gcc.gnu.org/), 91 bytes
```
f(p,r,d,D,s,l)char*p;{for(r=D=0;d=p[1]-*p,*++p;D=d){s=d&&d==D;r+=!d+s*l;l=3-2*s;}return r;}
```
[Try it online!](https://tio.run/##LY9Nb4MwDIbP5Fd4TK0ChClQoJuy9MSx2m0nxoGRMlIxQAkcporfzsKHfbAf2Xr9uvR/ynKeK9wTRQRJiSaNU9aFcnv2qDqFFU85ZYL3WZD7bk9cz@tZyoXz0Fwcj4LzlCmPPwlPuw1r@MkPXc0mdRtG1YJi0/ws27IZxQ3e9SBk91JfEJLtAL@FbLEDD2Qt98DVWQ58QcsuimAJm6zwHcTRKdmgu7@GSRRvMMokjuJ9UtemPdMN/mpKwyjaBe6UnuMdZPEWmFzh4/N6RdbEkGU@BbyYksYCZaAzmTOQnrf6s3plZhW2Dxr8CxzEV2uTdYdAhZfqOEZkQtb@NmVoQvM/ "C (gcc) – Try It Online")
Idea stolen from [Felipe Nardi Batista's Python answer](https://codegolf.stackexchange.com/a/141659/9296).
[Answer]
# [Pyth](https://pyth.readthedocs.io), ~~48~~ 42 bytes
Direct port from my python answer. Takes input as a byte-string with lowercase letters as: b'aa11111'.
This is my first time coding in Pyth, so any tips are welcome :D
```
KJ=b0VQ=d&KqK-NJ=+b+qNJ*dZ=Z-3yd=K-NJ=JN;b
```
[Try it here](https://pyth.herokuapp.com/?code=KJ%3Db0VQ%3Dd%26KqK-NJ%3D%2Bb%2BqNJ*dZ%3DZ-3yd%3DK-NJ%3DJN%3Bb&input=b%27aa11111%27&debug=0)
[Answer]
# JavaScript, ~~216~~ ~~192~~ ~~186~~ ~~202~~ 201 bytes
```
function f(s){var a=s.split(" "),c=a[1],a=a[0],r,h=b=i=p=0;for(i=0;i<4;i++){if(i<2&(r=a[i+1]-a[i]==a[i+2]-a[i+1])){p++;b=2}if(i>0){if(a[i]==a[i-1]){p++;h++}if(i<3&c[i]==c[i-1])p++}}return h==4?p+b:p-b}
```
### Unminified
```
function f(s){
    var a=s.split(" "),c=a[1],a=a[0],r,h=b=i=p=0;
    for(i=0;i<4;i++){
        if(i<2&(r=a[i+1]-a[i]==a[i+2]-a[i+1])){
            p++;
            b=2
        }
        if(i>0){
            if(a[i]==a[i-1]){
                p++;
                h++;
            }
            if(i<3&c[i]==c[i-1]) 
                p++;
        }
    }
    return h==4?p+b:p-b
}
```
Edit history:
* Narrowed down the code to only work with `0000 XXX` format. (-24 bytes)
* Edits as suggested by @Titus. (-6 bytes)
* fixed a bug where four identical numbers gave a score of 7 instead of 3. (+16 bytes)
* Removed last semi-colon. (-1 byte)
* Fixed a typo in the code. (no byte change)
]