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
|
||||
|
||||
@ -9,7 +9,7 @@ Solution for problem 49 of Project Euler
|
||||
https://projecteuler.net/problem=49
|
||||
"""
|
||||
|
||||
from utils import timeit, list_primes
|
||||
from utils import list_primes, timeit
|
||||
|
||||
|
||||
@timeit("Problem 49")
|
||||
@ -20,16 +20,23 @@ def compute():
|
||||
(i) each of the three terms are prime, and,
|
||||
(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,
|
||||
exhibiting this property, but there is one other 4-digit increasing sequence.
|
||||
There are no arithmetic sequences made up of three 1-, 2-, or 3-digit
|
||||
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 = []
|
||||
primes_list = sorted(set(list_primes(10_000)) - set(list_primes(1_000)))
|
||||
|
||||
for number in primes_list:
|
||||
if set(list(str(number))) == set(list(str(number+3330))) == set(list(str(number+6660))):
|
||||
if (
|
||||
set(list(str(number)))
|
||||
== 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
|
||||
@ -37,5 +44,4 @@ def compute():
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
print(f"Result for Problem 49: {compute()}")
|
||||
print(f"Result for Problem 49 is {compute()}")
|
||||
|
Loading…
x
Reference in New Issue
Block a user