Compare commits
4 Commits
233fc85708
...
a1fa273624
| Author | SHA1 | Date | |
|---|---|---|---|
| a1fa273624 | |||
| cf417eaca2 | |||
| 605c9c7f7f | |||
| e6ed590b73 |
@@ -29,11 +29,10 @@ def compute():
|
||||
"""
|
||||
|
||||
ans = set()
|
||||
pandigital = ["1", "2", "3", "4", "5", "6", "7", "8", "9"]
|
||||
pandigital = [str(number) for number in range(1, 10)]
|
||||
|
||||
for x in range(1, 100):
|
||||
for y in range(100, 10_000):
|
||||
# product = x * y
|
||||
if sorted(str(x) + str(y) + str(x * y)) == pandigital:
|
||||
ans.add(x * y)
|
||||
|
||||
|
||||
@@ -9,11 +9,7 @@ Solution for problem 036 of Project Euler
|
||||
https://projecteuler.net/problem=36
|
||||
"""
|
||||
|
||||
from project_euler_python.utils import timeit
|
||||
|
||||
|
||||
def is_palidrome(num):
|
||||
return str(num) == str(num)[::-1]
|
||||
from project_euler_python.utils import is_palindrome, timeit
|
||||
|
||||
|
||||
@timeit("Problem 036")
|
||||
@@ -28,7 +24,7 @@ def compute():
|
||||
|
||||
ans = 0
|
||||
for i in range(1, 1_000_001, 2):
|
||||
if is_palidrome(i) and is_palidrome(bin(i)[2:]):
|
||||
if is_palindrome(i) and is_palindrome(bin(i)[2:]):
|
||||
ans += i
|
||||
|
||||
return ans
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ def compute():
|
||||
"""
|
||||
|
||||
ans = []
|
||||
pandigital = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
|
||||
pandigital = [str(number) for number in range(1, 10)]
|
||||
|
||||
for n in permutations(pandigital):
|
||||
n_ = "".join(n)
|
||||
|
||||
Reference in New Issue
Block a user