Пример #1
0
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
Пример #2
0
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
Пример #3
0
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
Пример #4
0
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
Пример #5
0
def main():
    total = 0
    for i in permutePandigital():
        numLst = list(i)
        if checkSubStrDiv(numLst):
            total += reverseDigitize(numLst)

    print total
Пример #6
0
def main():
    total = 0
    for i in permutePandigital():
        numLst = list(i)
        if checkSubStrDiv(numLst):
            total += reverseDigitize(numLst)

    print total
Пример #7
0
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)
Пример #8
0
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
Пример #9
0
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