Adopted new convention from template
This commit is contained in:
parent
d464a0f434
commit
4fbb158c70
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python
|
||||||
"""
|
"""
|
||||||
Created on 18 Sep 2021
|
Created on 18 Sep 2021
|
||||||
|
|
||||||
@ -9,7 +9,7 @@ Solution for problem 49 of Project Euler
|
|||||||
https://projecteuler.net/problem=49
|
https://projecteuler.net/problem=49
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from utils import timeit, list_primes
|
from utils import list_primes, timeit
|
||||||
|
|
||||||
|
|
||||||
@timeit("Problem 49")
|
@timeit("Problem 49")
|
||||||
@ -20,22 +20,28 @@ def compute():
|
|||||||
(i) each of the three terms are prime, and,
|
(i) each of the three terms are prime, and,
|
||||||
(ii) each of the 4-digit numbers are permutations of one another.
|
(ii) each of the 4-digit numbers are permutations of one another.
|
||||||
|
|
||||||
There are no arithmetic sequences made up of three 1-, 2-, or 3-digit primes,
|
There are no arithmetic sequences made up of three 1-, 2-, or 3-digit
|
||||||
exhibiting this property, but there is one other 4-digit increasing sequence.
|
primes, exhibiting this property, but there is one other 4-digit increasing
|
||||||
|
sequence.
|
||||||
|
|
||||||
What 12-digit number do you form by concatenating the three terms in this sequence?
|
What 12-digit number do you form by concatenating the three terms in this
|
||||||
|
sequence?
|
||||||
"""
|
"""
|
||||||
|
|
||||||
ans = []
|
ans = []
|
||||||
primes_list = sorted(set(list_primes(10_000)) - set(list_primes(1_000)))
|
primes_list = sorted(set(list_primes(10_000)) - set(list_primes(1_000)))
|
||||||
|
|
||||||
for number in primes_list:
|
for number in primes_list:
|
||||||
if set(list(str(number))) == set(list(str(number+3330))) == set(list(str(number+6660))):
|
if (
|
||||||
if number+3330 in primes_list and number+6660 in primes_list:
|
set(list(str(number)))
|
||||||
ans.append(str(number)+str(number+3300)+str(number+6660))
|
== set(list(str(number + 3330)))
|
||||||
|
== set(list(str(number + 6660)))
|
||||||
|
):
|
||||||
|
if number + 3330 in primes_list and number + 6660 in primes_list:
|
||||||
|
ans.append(str(number) + str(number + 3300) + str(number + 6660))
|
||||||
# return the second one
|
# return the second one
|
||||||
return ans[1]
|
return ans[1]
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
print(f"Result for Problem 49 is {compute()}")
|
||||||
print(f"Result for Problem 49: {compute()}")
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user