Project Euler 4
Python
import time
def isPalindrome(n):
n = list(str(n))
start = 0
back = len(n) - 1
while start < back:
if(n[start] == n[back]):
start += 1
back -= 1
else:
return False
return True
i = 100
answer = 0
start_time = time.time()
while i < 1000:
j = i
while j < 1000:
if isPalindrome(i * j) and i * j > answer:
answer = i * j
j += 1
i += 1
print answer, time.time() - start_time


I had my first “Sherlock Holmes” experience yesterday (by this, I mean that I was able to make inferences of small details and solve a problem). Though a small and pointless thing, I still felt rather ingenious. It all started when I received a text: