Skip to content

Commit

Permalink
euler 049 solution
Browse files Browse the repository at this point in the history
  • Loading branch information
kailanefelix committed Oct 13, 2021
1 parent 114b627 commit 87bc4e5
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions euler0XX/euler049.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from itertools import combinations, permutations
from numbertools import is_prime

answers = set()
for n in range(1000, 10000):
perms = {int(''.join(p)) for p in permutations(str(n))}

# remove permutations with less than 4 digits (leading 0) and that are not prime
perms = {p for p in perms if p >= 1000 and is_prime(p)}

if len(perms) < 3:
continue

for a, b, c in combinations(perms, r=3):
if a - b == b - c:
answers.add((a, b, c))

for a, b, c in answers:
print(f'{a}{b}{c}')

0 comments on commit 87bc4e5

Please sign in to comment.