def checkSubStrDiv(num): for i in xrange(1, 8): testNum = int(reverseDigitize(num[i:i + 3])) if testNum % savedPrimes[i - 1] != 0: return False else: return True
def checkSubStrDiv(num): for i in xrange(1, 8): testNum = int(reverseDigitize(num[i:i+3])) if testNum % savedPrimes[i-1] != 0: return False else: return True
def main(): testedSet = set() for i in xrange(300, 10000): if i % 100 == 0: print i cubeVal = i**3 cubeDigits = tuple(digitize(cubeVal)) perms = set([x for x in permutations(cubeDigits) if x > cubeDigits]) if perms.intersection(testedSet): testedSet = testedSet.union(perms) print '%s skipped' % (i, ) continue successes = 0 for perm in perms: if perm in testedSet: print '%s skipped' % (i, ) break else: testedSet.add(perm) perm = reverseDigitize(perm) if isCubeRoot(perm): successes += 1 if successes == 5: print cubeVal return cubeVal
def main(): testedSet = set() for i in xrange(300, 10000): if i % 100 == 0: print i cubeVal = i**3 cubeDigits = tuple(digitize(cubeVal)) perms = set([x for x in permutations(cubeDigits) if x > cubeDigits]) if perms.intersection(testedSet): testedSet = testedSet.union(perms) print '%s skipped' % (i,) continue successes = 0 for perm in perms: if perm in testedSet: print '%s skipped' % (i,) break else: testedSet.add(perm) perm = reverseDigitize(perm) if isCubeRoot(perm): successes += 1 if successes == 5: print cubeVal return cubeVal
def main(): total = 0 for i in permutePandigital(): numLst = list(i) if checkSubStrDiv(numLst): total += reverseDigitize(numLst) print total
def main(): digits = [int(x) for x in '123456789'] perms = permutations(digits) validProducts = set() for perm in perms: multiplicand = reverseDigitize([perm[0], perm[1]]) multiplier = reverseDigitize([perm[2], perm[3], perm[4]]) product = reverseDigitize([perm[5], perm[6], perm[7], perm[8], ]) if multiplicand * multiplier == product: validProducts.add(product) multiplicand = reverseDigitize([perm[0]]) multiplier = reverseDigitize([perm[1], perm[2], perm[3], perm[4]]) product = reverseDigitize([perm[5], perm[6], perm[7], perm[8], ]) if multiplicand * multiplier == product: validProducts.add(product) print sum(validProducts) return sum(validProducts)
def main(): fourDigitPrimes = [i for i in savedPrimes if 1000 < i < 9999] fourDigitPrimeSet = set(fourDigitPrimes) for i in fourDigitPrimes: perms = [reverseDigitize(x) for x in permutations(digitize(i))] perms = list(set([x for x in perms if x in fourDigitPrimeSet])) if len(perms) < 3: continue perms = sorted(perms) if checkArithSeq(perms): print perms