def run(): L = [] for i in reversed(range(100, 1000)): for j in reversed(range(100, 1000)): if is_palindrome(i * j): L.append(i * j) print max(L)
def palindrome_products(start, end): lower_bound = start def countdown(): return takewhile(lambda n: n > lower_bound, range(end, 0, -1)) candidates = ((x * y, min(x, y)) for x in countdown() for y in countdown() if is_palindrome(x * y)) for palindrome, new_lower_bound in candidates: yield palindrome lower_bound = new_lower_bound
def run(): N = 0 for i in range(1000000): if is_palindrome(i) and is_palindrome(binstr(i)): N += i print N
def double_base_palindromes(limit): return (x for x in range(1, limit, 2) if is_palindrome(str(x)) and is_palindrome(to_bin(x)))