def solve(): l = [x for x in mtools.sieve_primes(10000) if len(str(x)) == 4] i = 0 while i < len(l): s = set(l) lp = [int(x) for x in mtools.permute(list(str(l[i])))] si = set(lp) & s li = list(si) li.sort() for j in range(len(li)-2): for k in range(j+1,len(li)-1): d = li[k] - li[j] if (li[k]+d) in li: if li[j] != 1487: return str(li[j]) + str(li[k]) + str(li[k]+d) l = list(s - si)
def solve(): l = mtools.permute(list('1234567890')) l2 = [x for x in l if divisible(x)] l3 = [int(x) for x in l2] return sum(l3)