Project Euler 4: (Iron)Python
- by Ben Griswold
In my attempt to learn (Iron)Python out in the open, here’s my solution for Project Euler Problem 4.
As always, any feedback is welcome.
# Euler 4
# http://projecteuler.net/index.php?section=problems&id=4
# Find the largest palindrome made from the product of
# two 3-digit numbers. A palindromic number reads the
# same both ways. The largest palindrome made from the
# product of two 2-digit numbers is 9009 = 91 x 99.
# Find the largest palindrome made from the product of
# two 3-digit numbers.
import time
start = time.time()
def isPalindrome(s):
return s == s[::-1]
max = 0
for i in xrange(100, 999):
for j in xrange(i, 999):
n = i * j;
if (isPalindrome(str(n))):
if (n > max): max = n
print max
print "Elapsed Time:", (time.time() - start) * 1000, "millisecs"
a=raw_input('Press return to continue')