In [1]:
def is_palindromic_number(x):
    x = str(x)
    return x == x[::-1]

In [2]:
is_palindromic_number(9009)


Out[2]:
True

In [3]:
is_palindromic_number(90109)


Out[3]:
True

In [4]:
is_palindromic_number(90019)


Out[4]:
False

In [5]:
highest_palindromic_number = 0
for i in range(100, 1000)[::-1]:
    for j in range(100, 1000)[::-1]:
        if j > i:
            continue
        k = i * j
        if is_palindromic_number(k) and k > highest_palindromic_number:
            # print i, j, k
            highest_palindromic_number = k
print highest_palindromic_number


906609

In [6]:
def find_highest_palindromic_number(a, b):
    highest_palindromic_number = 0
    for i in range(a, b)[::-1]:
        for j in range(a, b)[::-1]:
            if j > i:
                continue
            k = i * j
            if is_palindromic_number(k) and k > highest_palindromic_number:
                # print i, j, k
                highest_palindromic_number = k
    return highest_palindromic_number

In [7]:
find_highest_palindromic_number(100, 1000)


Out[7]:
906609

In [8]:
%timeit find_highest_palindromic_number(100, 1000)


1 loops, best of 3: 539 ms per loop

In [9]:
def find_highest_palindromic_number(a, b):
    highest_palindromic_number = 0
    for i in range(a, b)[::-1]:
        for j in range(a, b)[::-1]:
            if j > i:
                continue
            k = i * j
            if k > highest_palindromic_number and is_palindromic_number(k):
                # print i, j, k
                highest_palindromic_number = k
    return highest_palindromic_number

In [10]:
find_highest_palindromic_number(100, 1000)


Out[10]:
906609

In [11]:
%timeit find_highest_palindromic_number(100, 1000)


10 loops, best of 3: 139 ms per loop

In [ ]: