mirror of
https://github.com/correl/euler.git
synced 2024-11-23 19:19:53 +00:00
Optimizations
git-svn-id: file:///srv/svn/euler@76 e5f4c3ec-3c0c-11df-b522-21efaa4426b5
This commit is contained in:
parent
5dacf3f6b9
commit
99417e9205
1 changed files with 2 additions and 2 deletions
4
e041.py
4
e041.py
|
@ -9,7 +9,7 @@ from e007 import is_prime
|
||||||
from e035 import permutations
|
from e035 import permutations
|
||||||
|
|
||||||
def pandigital_prime_generator(n):
|
def pandigital_prime_generator(n):
|
||||||
if n not in [3, 7, 9]:
|
if n > 7:
|
||||||
raise Exception('Invalid pandigital prime length')
|
raise Exception('Invalid pandigital prime length')
|
||||||
for end in [3, 7, 9]:
|
for end in [3, 7, 9]:
|
||||||
digits = range(1, n + 1)
|
digits = range(1, n + 1)
|
||||||
|
@ -22,7 +22,7 @@ def pandigital_prime_generator(n):
|
||||||
yield number
|
yield number
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
for len in [9, 7, 3]:
|
for len in range(7, 2, -1):
|
||||||
for n in sorted(pandigital_prime_generator(len), reverse=True):
|
for n in sorted(pandigital_prime_generator(len), reverse=True):
|
||||||
print 'Pandigital Prime:', n
|
print 'Pandigital Prime:', n
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue