Adopted new convention from template
This commit is contained in:
parent
b36423bd9c
commit
6b55d7b25e
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python
|
||||||
"""
|
"""
|
||||||
Created on 09 Apr 2021
|
Created on 09 Apr 2021
|
||||||
|
|
||||||
@ -9,7 +9,8 @@ Solution for problem 37 of Project Euler
|
|||||||
https://projecteuler.net/problem=37
|
https://projecteuler.net/problem=37
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from utils import timeit, list_primes, is_prime
|
from utils import is_prime, list_primes, timeit
|
||||||
|
|
||||||
|
|
||||||
def is_truncatable_prime(number):
|
def is_truncatable_prime(number):
|
||||||
num_str = str(number)
|
num_str = str(number)
|
||||||
@ -19,6 +20,7 @@ def is_truncatable_prime(number):
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
@timeit("Problem 37")
|
@timeit("Problem 37")
|
||||||
def compute():
|
def compute():
|
||||||
"""
|
"""
|
||||||
@ -32,15 +34,16 @@ def compute():
|
|||||||
|
|
||||||
NOTE: 2, 3, 5, and 7 are not considered to be truncatable primes.
|
NOTE: 2, 3, 5, and 7 are not considered to be truncatable primes.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
ans = 0
|
ans = 0
|
||||||
primes = list_primes(1_000_000)
|
primes = list_primes(1_000_000)
|
||||||
# Statement of the problem says this
|
# Statement of the problem says this
|
||||||
for number in primes[4:]:
|
for number in primes[4:]:
|
||||||
if is_truncatable_prime(number):
|
if is_truncatable_prime(number):
|
||||||
ans += number
|
ans += number
|
||||||
|
|
||||||
return ans
|
return ans
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
print(f"Result for Problem 37 is {compute()}")
|
||||||
print(f"Result for Problem 37: {compute()}")
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user