(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)
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.
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.