Untitled

mail@pastecode.io avatar
unknown
python
a month ago
549 B
0
Indexable
Never
from itertools import product


def count_even(number):
    return sum(1 for n in number if int(n) % 2 == 0)


def seven(number):
    for i in range(len(number) - 2):
        if number[i + 1] == "7":
            if int(number[i]) % 2 == 1 or int(number[i + 2]) % 2 == 1:
                return False

    return not (int(number[-1]) == 7 and int(number[-2]) % 2 != 0)


numbers = [n for n in product("01234567", repeat=7) if n[0] != '0']
cnt = 0

for number in numbers:
    if count_even(number) == 2 and seven(number):
        cnt += 1

print(cnt)
Leave a Comment