Exemple #1
0
def solve43(digits):
    with_property = []
    for perm in list(itertools.permutations(digits)):
        if perm[0] == 0:
            continue
        if check_property(perm):
            with_property.append(listmath.list_to_int(perm))
    return sum(with_property)
Exemple #2
0
def check_property(perm):
    prime_gen = primes.gen_primes()
    for y in range(1, 8):
        x = listmath.list_to_int(perm[y : y + 3])
        p = next(prime_gen)
        if x % p != 0:
            return False
    return True
Exemple #3
0
def solve41(digits):
    for perm in itertools.permutations(digits):
        print listmath.list_to_int(perm)
        if primes.is_prime(listmath.list_to_int(perm)):
            return listmath.list_to_int(perm)
    solve41(digits[1:])