def brute_force_quadratic_primes(): _, primes_under_1k = prime_utils.load_primes(max_number=1000) is_prime, primes_under_10m = prime_utils.load_primes(max_number=10000000) max_consecutive = 0 final_b = final_c = 0 for b in range(-999, 1001, 2): for c in list(map(lambda p: -1 * p, primes_under_1k)) + primes_under_1k: consecutive = get_consecutive_primes(is_prime, b, c) if consecutive > max_consecutive: max_consecutive = consecutive final_b, final_c = b, c return max_consecutive, final_b, final_c
# Why the f**k are there so many pandigital questions? import collections import os import sys # This bit is ridiculous module_path = os.path.abspath(os.path.join('..')) if module_path not in sys.path: sys.path.append(module_path) from utils import prime_utils is_prime, primes = prime_utils.load_primes() def is_pandigital(n): return set(str(n)) == set(map(str, range( 1, len(str(n)) + 1))) and collections.Counter( str(n)).most_common()[0][1] == 1 for prime in primes: if is_pandigital(prime): print(prime)