示例#1
0
"""
if __name__ == "__main__":
    import sys, os
    sys.path.append( os.path.join( os.getcwd(), '..' ) )

from euler_tools.misc import is_palindrome

digits = 2

min_value = 100
max_value = 999

#~ print "is_palindrome(11): " % is_palindrome(11)
#~ print is_palindrome(12321)

solution_found = False
solution = None
for n in range(max_value, min_value, -1):
    for m in range(max_value, min_value, -1):
        product = n * m
        if is_palindrome(product):
            if not solution or product > solution:
                print "%s * %s = %s" % (n, m, product)
                solution = product
            #~ solution_found = True
            #~ break


    if solution_found:
        break
示例#2
0
from euler_tools.misc import is_palindrome

sum = 0
for n in range(1, 1000000):
#~ for n in range(1, 100):
    if is_palindrome(n):
        binary_string = bin(n)[2:]
        if is_palindrome(binary_string):
            print "%s\t%s"  % (n, binary_string)
            sum += n

print "Answer: %s" % sum