def allSets(): digits = list(range(10)) allSet = [set(x) for x in permutations.chooseN(digits,6)] for set1 in allSet: if(6 in set1): set1.add(9) elif(9 in set1): set1.add(6) return permutations.chooseN(allSet,2)
def cleanList(total): total = list(set(total)) total = [int(x) for x in total if x != None and x % 1 == 0 and x > 0] total.sort() for x in range(1,len(total)+1): if(total[x-1] != x): return x-1 return len(total)-1 def totalRange(e): ways = pr.permute(e) total = [] for way in ways: y = addAllOpers(way) for z in y: total += solveAllWays(z) return cleanList(total) digs = [x for x in range(10)] combos = pr.chooseN(digs,4) max = 0 maxE = None for c in combos: x = totalRange(c) print(x) if x > max: max = x maxE = c print(max,maxE)
#Solved import prime as pi import permutations as pr sieve = [x for x in pi.sieve(10000) if x > 1000] dict1 = {} def hash1(x): return ''.join(sorted(str(x))) for x in sieve: h = hash1(x) dict1[h] = dict1.get(h,[]) + [x] keys = dict1.keys() triplets = [] for key in keys: x = dict1[key] if(len(x) >= 3): triplets.append(x) for y in triplets: for x in pr.chooseN(y,3): x.sort() if(x[2] - x[1] == x[1] - x[0]): x = [str(a) for a in x] print(''.join(x),"Done") break
total = list(set(total)) total = [int(x) for x in total if x != None and x % 1 == 0 and x > 0] total.sort() for x in range(1, len(total) + 1): if (total[x - 1] != x): return x - 1 return len(total) - 1 def totalRange(e): ways = pr.permute(e) total = [] for way in ways: y = addAllOpers(way) for z in y: total += solveAllWays(z) return cleanList(total) digs = [x for x in range(10)] combos = pr.chooseN(digs, 4) max = 0 maxE = None for c in combos: x = totalRange(c) print(x) if x > max: max = x maxE = c print(max, maxE)