[WIP] too slow
This commit is contained in:
parent
6c0a3d967f
commit
037f4c0f8d
@ -1,5 +1,3 @@
|
||||
testing
|
||||
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Created on 13 Oct 2021
|
||||
@ -11,23 +9,34 @@ Solution for problem 60 of Project Euler
|
||||
https://projecteuler.net/problem=60
|
||||
"""
|
||||
|
||||
from utils import timeit
|
||||
from itertools import permutations
|
||||
from utils import timeit, list_primes
|
||||
|
||||
|
||||
@timeit("Problem 60")
|
||||
def compute():
|
||||
"""
|
||||
The primes 3, 7, 109, and 673, are quite remarkable. By taking any two
|
||||
primes and concatenating them in any order the result will always be prime.
|
||||
For example, taking 7 and 109, both 7109 and 1097 are prime. The sum of
|
||||
these four primes, 792, represents the lowest sum for a set of four primes
|
||||
The primes 3, 7, 109, and 673, are quite remarkable. By taking any two
|
||||
primes and concatenating them in any order the result will always be prime.
|
||||
For example, taking 7 and 109, both 7109 and 1097 are prime. The sum of
|
||||
these four primes, 792, represents the lowest sum for a set of four primes
|
||||
with this property.
|
||||
|
||||
Find the lowest sum for a set of five primes for which any two primes
|
||||
Find the lowest sum for a set of five primes for which any two primes
|
||||
concatenate to produce another prime.
|
||||
"""
|
||||
|
||||
# Your code goes here
|
||||
primes_list = list_primes(10_000)
|
||||
|
||||
for nums in permutations(primes_list, 5):
|
||||
for n1, n2 in permutations(nums, 2):
|
||||
if int(str(n1) + str(n2)) not in primes_list:
|
||||
break
|
||||
primes = sum(nums)
|
||||
print(nums)
|
||||
# break
|
||||
|
||||
return primes
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
Loading…
x
Reference in New Issue
Block a user