Exemplo n.º 1
0
from black_box import ispalindrome

allnums = []
allbins = []
for num in range(1,1000000,2):
	if ispalindrome(str(num)):
		inbin = str(bin(num))
		binst = inbin[2:len(inbin)]
		if ispalindrome(binst):
			allnums.append(num)
			#allbins.append(binst)

print (allnums)
print (sum(allnums))
Exemplo n.º 2
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)
Exemplo n.º 3
0
# A palindromic number reads the same both ways. The largest palindrome made 
# from the product of two 2-digit numbers is 9009 = 91 × 99.

# Find the largest palindrome made from the product of two 3-digit numbers.

from black_box import ispalindrome

largest = 0

for i in range(100,1000):
    for j in range(i,1000):
        num = i*j
        if( ispalindrome(str(num)) ):
            if(num > largest):
                largest = num

print(largest)