> "7777...*8?!??!*", exclaimed Bob, "I missed it again!  Argh!"  Every time there's an interesting number coming up, he notices and then promptly forgets.  Who *doesn't* like catching those one-off interesting mileage numbers?

Let's make it so Bob **never** misses another interesting number.  We've hacked into his car's computer, and we have a box hooked up that reads mileage numbers.  We've got a box glued to his dash that lights up yellow or green depending on whether it receives a `1` or a `2` (respectively).

It's up to you, intrepid warrior, to glue the parts together.  Write the function that parses the mileage number input, and returns a `2` if the number is "interesting" (see below), a `1` if an interesting number occurs within the next two miles, or a `0` if the number is not interesting.

**Note:** In Haskell, we use `No`, `Almost` and `Yes` instead of `0`, `1` and `2`.

## "Interesting" Numbers

Interesting numbers are 3-or-more digit numbers that meet one or more of the following criteria:

```if-not:ruby,python
* 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` or `73837`
* The digits match one of the values in the `awesomePhrases` array
```
```if:ruby,python
* 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` or `73837`
* The digits match one of the values in the `awesome_phrases` array
```

> † For incrementing sequences, `0` should come after `9`, and not before  `1`, as in `7890`.
> ‡ For decrementing sequences, `0` should come after `1`, and not before  `9`, as in `3210`.

So, you should expect these inputs and outputs:

```python
# "boring" numbers
is_interesting(3, [1337, 256])    # 0
is_interesting(3236, [1337, 256]) # 0

# progress as we near an "interesting" number
is_interesting(11207, []) # 0
is_interesting(11208, []) # 0
is_interesting(11209, []) # 1
is_interesting(11210, []) # 1
is_interesting(11211, []) # 2

# nearing a provided "awesome phrase"
is_interesting(1335, [1337, 256]) # 1
is_interesting(1336, [1337, 256]) # 1
is_interesting(1337, [1337, 256]) # 2
```

## Error Checking

* A number is only interesting if it is greater than `99`!
* Input will *always* be an integer greater than `0`, and less than `1,000,000,000`. 
* The `awesomePhrases` array will always be provided, and will always be an array, but may be empty.  (Not *everyone* thinks numbers spell funny words...)
* You should only ever output `0`, `1`, or `2`.

Difficulty: interview

Starter code:

def is_interesting(number, awesome_phrases):
	

Solutions:
def is_incrementing(number): return str(number) in '1234567890'
def is_decrementing(number): return str(number) in '9876543210'
def is_palindrome(number):   return str(number) == str(number)[::-1]
def is_round(number):        return set(str(number)[1:]) == set('0')

def is_interesting(number, awesome_phrases):
    tests = (is_round, is_incrementing, is_decrementing,
             is_palindrome, awesome_phrases.__contains__)
       
    for num, color in zip(range(number, number+3), (2, 1, 1)):
        if num >= 100 and any(test(num) for test in tests):
            return color
    return 0

import re
def is_sequential(string):
    return string in "1234567890" or string in "9876543210"

def is_interesting(number, awesome_phrases):
    print (number)
    interestingness = 2
    for i in (number, number + 1, number + 2):
        if (number != i):
            interestingness = 1
        if (i < 100):
            continue
        if (i in awesome_phrases):
            return interestingness
        i = str(i)
        if re.match(r"^\d0+$", i):
            return interestingness
        if i == i[::-1]:
            return interestingness
        if is_sequential(i):
            return interestingness
        if re.match(r"^(\d)\1+$", i):
            return interestingness
    
    
    return 0

def is_good(n, awesome):
    return n in awesome or str(n) in "1234567890 9876543210" or str(n) == str(n)[::-1] or int(str(n)[1:]) == 0

def is_interesting(n, awesome):
    if n > 99 and is_good(n, awesome):
        return 2
    if n > 97 and (is_good(n + 1, awesome) or is_good(n + 2, awesome)):
        return 1
    return 0

def is_interesting(n, awesome_phrases):
    import math
    for m in range(3):
        s = str(n + m)
        if len(s) > 2 and (zf(s) or sd(s) or seqinc(s) or seqdec(s) or pal(s) or awe(s, awesome_phrases)):
            if m == 0: return 2
            else: return 1
    return 0
    
def awe(s, l):
    return s in [str(x) for x in l]
    
def pal(s):
    return s == s[::-1]
    
def seqdec(s):
    a = '9876543210'
    for i in range(len(s)-1):
        if a.index(s[i]) + 1 != a.index(s[i+1]): return False
    return True
    
def seqinc(s):
    a = '1234567890'
    for i in range(len(s)-1):
        if a.index(s[i]) + 1 != a.index(s[i+1]): return False
    return True

def sd(s):
    for i in range(len(s)-1):
        if s[i] != s[i+1]: return False
    return True

def zf(s):
    for i in range(1, len(s)):
        if s[i] != '0': return False
    return True

def is_interesting(number, awesome_phrases):
    for i in [number, number+1, number+2]:
        if i<100 :
            continue
        j=str(i)
        if any([
            i in awesome_phrases,
            all([j[x]=='0' for x in range(1,len(j))]),
            all([j[x]==j[0] for x in range(1,len(j))]),
            j == j[::-1],
            j in '1234567890',
            j in '9876543210'
                ]):
            return 2-bool(number-i)
    return 0

def is_interesting(number, awesome_phrases):
    for r, num in zip((2, 1, 1), range(number, number + 3)):
        num_str = str(num)
        if num in awesome_phrases or num > 99 and (int(num_str[1:]) == 0 or num_str[::-1] == num_str or num_str in '1234567890' or num_str in '9876543210'):
            return r
    return 0

def is_interesting(number, awesome_phrases):
    def check(n):
        nonlocal awesome_phrases
        n = str(n)
        test0 = lambda x: len(x) > 2
        test1 = lambda x: set(x[1:]) == set("0")
        test2 = lambda x: len(set(x)) == 1
        test3 = lambda x: all((int(b) or 10) - (int(a) or 10) == 1 for a, b in zip(x, x[1:]))
        test4 = lambda x: all(int(a) - int(b) == 1 for a, b in zip(x, x[1:]))
        test5 = lambda x: x == x[::-1]
        test6 = lambda x: int(x) in awesome_phrases
        return test0(n) and (test1(n) or test2(n) or test3(n) or test4(n) or test5(n) or test6(n))
    return int((check(number) and 2) or (check(number+1) or check(number+2)))

is_exact = lambda n, sn, p: n>99 and (
        all(d=='0' for d in sn[1:]) or
        all(d == sn[0] for d in sn) or
        sn in '1234567890' or
        sn in '9876543210' or
        sn == sn[::-1] or 
        n in p)

is_interesting = lambda n, p: next([_f for _f in (
    1+(v==n) if is_exact(v, str(v), p) else 0 for v in range(n,n+3)) if _f],0)


isZeros = lambda nStr : sum(map(int,list(nStr))) == int(nStr[0])
isAll   = lambda nStr : nStr == nStr[0]*len(nStr)
isInc   = lambda nStr : nStr in "9876543210 1234567890"
isPalin = lambda nStr : nStr == nStr[::-1]

def is_interesting(number, awesome_phrases):
    for i in range(3):
        nStr = str(number+i)
        if int(nStr)>99 and ( isZeros(nStr) or isAll(nStr) or isInc(nStr) or isPalin(nStr) or int(nStr) in awesome_phrases ):
            return {0:2, 1:1, 2:1}[i]
    return 0

def is_interesting(number, awesome_phrases, within=2):
    if number in awesome_phrases: return 2
    if number >= 100:
        n = str(number)
        if set(n[1:]) == {'0'}: return 2 # Finishing by 0
        if len(set(n)) == 1: return 2    # Same digit
        if n in '1234567890': return 2   # Incrementing
        if n in '9876543210': return 2   # Decrementing
        if n == n[::-1]: return 2        # Palindrome
    return any(is_interesting(number+i+1, awesome_phrases, 0) for i in range(within))