def the_primes(): from primes import find_next_prime next_prime = find_next_prime(2 * (10 ** 9)) while next_prime < 2*(10 ** 9) + 2000: yield next_prime next_prime = find_next_prime(next_prime+1)
bstr = bstr[1:] index = index + d indices.append(index) return indices def addGroup(p): group_size = 0 best = '' ps = str(p) count = Counter(ps) for c, v in count.most_common(): if v < 2: break indices = createIndices(ps, c, v) for index in indices: p_map.setdefault(index, []).append(p) if len(p_map[index]) > group_size: group_size = len(p_map[index]) best = index return best if __name__ == '__main__': n = 0 for _ in count(0): n = find_next_prime(n+1) group = addGroup(n) if group and len(p_map[group]) == 8: print "{}".format(sorted(p_map[group])[0]) break
def try_prime_test(possible_set): ps = list(possible_set) for i in range(len(ps)): for j in range(i+1, len(ps)): if not try_prime_pair(ps[i], ps[j]): return False return True def add_new_primes(new, old): if frozenset(new) in old: return new_sets = [frozenset(new)] for prime_set in old: possible_set = prime_set.union(new) if possible_set not in old and possible_set not in new_sets and try_prime_test(possible_set): new_sets.append(possible_set) if len(possible_set) == 5: print sum(possible_set) sys.exit(0) old.update(new_sets) if __name__ == '__main__': prime_sets = set() current_prime = 10 while True: current_prime = primes.find_next_prime(current_prime + 1) new_primes = split_prime(current_prime) if new_primes: add_new_primes(new_primes, prime_sets)