1
0
Fork 0

Problem 51: added breaking out of loops when first answer is found.

This commit is contained in:
Jonathan Chan 2016-12-23 11:35:27 -08:00
parent 80054b70e3
commit 0f1409f803
1 changed files with 5 additions and 0 deletions

5
51.py
View File

@ -9,6 +9,7 @@ patterns = list(set(list(it.permutations(permupattern, length))))
digits = list(it.product(range(0, 10), repeat=length-repeats))
for pattern in patterns:
breakout = False
for digit in digits:
family = []
for i in range(0, 10):
@ -25,3 +26,7 @@ for pattern in patterns:
family.append(num)
if family and len(filter(lambda n: gmpy2.is_prime(n), family)) == familysize:
print family
breakout = True
break
if breakout:
break