Skip to content
Snippets Groups Projects
Commit aa991260 authored by Taddeus Kroes's avatar Taddeus Kroes
Browse files

Solved 49

parent acdb419a
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python
from itertools import permutations, combinations
from utils import primes_until, digits, add
from sys import exit
def concat(digits):
return int(reduce(add, digits))
def suited(n):
return n > 999 and n not in (1487, 4817, 8147) and n in primes
primes = [p for p in primes_until(10000) if p > 999]
for p in primes:
perm = map(concat, permutations(str(p)))
for a, b, c in set(combinations(perm, 3)):
if a >= b or a >= c or b >= c \
or b - a != c - b or b - a < 1000 \
or not all(map(suited, (a, b, c))):
continue
print '%d%d%d' % (a, b, c)
exit()
def add(a, b):
return a + b
def digits(n):
return [n] if n < 10 else digits(n / 10) + [n % 10]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment