Get rid of auxiliary function
This commit is contained in:
@@ -12,14 +12,6 @@ https://projecteuler.net/problem=41
|
||||
from project_euler_python.utils import is_prime, timeit
|
||||
|
||||
|
||||
def is_pandigital(number):
|
||||
number = sorted(str(number))
|
||||
check = [str(i) for i in range(1, len(number) + 1)]
|
||||
if number == check:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
@timeit("Problem 041")
|
||||
def compute():
|
||||
"""
|
||||
@@ -30,8 +22,10 @@ def compute():
|
||||
What is the largest n-digit pandigital prime that exists?
|
||||
"""
|
||||
|
||||
pandigital = [str(number) for number in range(1, 10)]
|
||||
|
||||
for ans in range(7654321, 1, -1):
|
||||
if is_pandigital(ans):
|
||||
if sorted(str(ans)) == pandigital[: len(str(ans))]:
|
||||
if is_prime(ans):
|
||||
return ans
|
||||
|
||||
|
||||
Reference in New Issue
Block a user