示例#1
0
文件: p43.py 项目: joshinda/code
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)
示例#2
0
文件: p43.py 项目: joshinda/code
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
示例#3
0
文件: p41.py 项目: joshinda/code
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:])