示例#1
0
def allProducts(thisList):
    prods = []
    for i in range(1, len(thisList) - 1):
        for j in range(i+1, len(thisList)):
            mult1 = list2int(thisList[0:i])
            mult2 = list2int(thisList[i:j])
            prodGuess = list2int(thisList[j:])
            if(mult1 * mult2 == prodGuess):
                prods.append(prodGuess)

    return prods
示例#2
0
def isAnswer(thisPerm):
    thisPermList = int2list(thisPerm)
    numGuess = list2int(thisPermList[0:1])
    numGuess2 = numGuess * 2
    if(numGuess2 == thisPermList[1:2]):
        #checks out...go on
    else:
示例#3
0
def checkPerm(thisPerm):
    """Checks whether this 0 to 9 pandigital meets the requrements
    of problem 43"""
    num1 = list2int(thisPerm[1:4])
    if(num1 % 2 != 0):
        return False
    num2 = list2int(thisPerm[2:5])
    if(num2 % 3 != 0):
        return False
    num3 = list2int(thisPerm[3:6])
    if(num3 % 5 != 0):
        return False
    num4 = list2int(thisPerm[4:7])
    if(num4 % 7 != 0):
        return False
    num5 = list2int(thisPerm[5:8])
    if(num5 % 11 != 0):
        return False
    num6 = list2int(thisPerm[6:9])
    if(num6 % 13 != 0):
        return False
    num7 = list2int(thisPerm[7:10])
    if(num7 % 17 != 0):
        return False

    return True
示例#4
0
allPerms = permutations(nums)

allPermsList = list(allPerms)

allChecked = []

numPerms = len(allPermsList)

for i in range(numPerms):
    if(i%10000 == 0):
        print('{0:.2f}'.format(100 * i / numPerms))
    perm = allPermsList[i]
    thisPermList = list(perm)
    if(checkPerm(thisPermList)):
        allChecked.append(list2int(thisPermList))

answer = sum(allChecked)

print(answer)










示例#5
0
from black_box import ispalindrome
from black_box import int2list
from black_box import list2int


foundNum = 0


for num in range(1, 10000):
    # print(num)
    found = False
    number = num
    for iterations in range(0,50):
        numList = []
        numList = int2list(number)
        numList.reverse()
        numRev = list2int(numList)

        number = number + numRev

        if(ispalindrome(int2list(number))):
            # print(num)
            # print(iterations)
            # print(number)
            found = True
            foundNum += 1
            break

print(9999-foundNum)
示例#6
0
# 28433x2^7830457+1

from black_box import int2list
from black_box import list2int
from math import pow

def longMultBy2(numList):
    newList = []

    carry = 0

    for digit in reversed(numList):
        newDigit = digit*2 + carry
        carry = int(newDigit / 10)
        newDigit = newDigit%10
        newList.append(newDigit)

    newList.reverse()

    return newList

numList = [0,0,0,0,0,0,0,0,0,2]
for i in range(1, 7830457):
    numList = longMultBy2(numList)

numResult = list2int(numList)

answer = numResult * 28433 + 1

print(answer)
示例#7
0
def isAnswer(thisPerm):
    thisPermList = int2list(thisPerm)
    numGuess = list2int(thisPermList[0:1])
    numGuess2 = numGuess * 2
    if(numGuess2 == thisPermList[1:2]):
        #checks out...go on
    else:
        #check for more digits



allPerms = permutations([1, 2, 3, 4, 5, 6, 7, 8, 9])

allPermsList = list(allPerms)

allPermsValue = []

for thisPerm in allPermsList:
    thisValue = list2int(list(thisPerm))
    allPermsValue.append(thisValue)

allPermsValue.sort()

#I now have a sorted list of all the permutations for digits 1 to 9...
#work from the largest down and see if I can create the desired effect?


for thisPerm in reversed(allPermsValue):
    print(thisPerm)