I tried some basic optimizations, to cut down on the number of operations for the general euler problem #4:
def is_palindrome(num):
return str(num) == str(num)[::-1]
def fn(n):
max_palindrome = 1
for x in range(n,1,-1):
for y in range(n,x-1,-1):
if is_palindrome(x*y) and x*y > max_palindrome:
max_palindrome = x*y
elif x * y < max_palindrome:
break
return max_palindrome
print fn(999)
Can I/how do I optimize this further? (assume it's the general solution, for factors of at most n rather than at most 999).