I completed the following question: https://www.codewars.com/kata/catching-car-mileage-numbers/train/pythonthe following question:
Write the function that parses the mileage number input, and returns a
2
if the number is "interesting" (see below), a1
if an interesting number occurs within the next two miles, or a0
if the number is not interesting."Interesting" Numbers
Interesting numbers are 3-or-more digit numbers that meet one or more of the following criteria:
- Any digit followed by all zeros:
100
,90000
- Every digit is the same number:
1111
- The digits are sequential, incementing†:
1234
- The digits are sequential, decrementing‡:
4321
- The digits are a palindrome:
1221
or73837
- The digits match one of the values in the
awesome_phrases
array† For incrementing sequences,
0
should come after9
, and not before1
, as in7890
.
‡ For decrementing sequences,0
should come after1
, and not before9
, as in3210
.