import MathFunctions, time start_time = time.time() print(sum(i for i in range(1,1000000) if MathFunctions.is_palindrome(i) and MathFunctions.is_palindrome ("{0:b}".format(i)))) print("--- %s seconds ---" % (time.time() - start_time))
''' 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. ''' import time, MathFunctions start_time = time.time() largest_parts = [] largest =0 for i in range(100, 999): for j in range(100, 999): product = i * j if MathFunctions.is_palindrome(product): if largest < product: largest = product if(len(largest_parts)>0): largest_parts.pop() largest_parts.pop() largest_parts.append(i) largest_parts.append(j) # print(largest_parts) print(largest) print("--- %s seconds ---" % (time.time() - start_time))