view problem4.py @ 14:49c96972949d default tip

#50 rewrite of solution
author Dominic Cleal <dominic@computerkb.co.uk>
date Mon, 01 Dec 2008 19:11:55 +0000
parents 1ca695e32f66
children
line wrap: on
line source

import math

def ispal(x):
	s = str(x)
	for i in range(0, int(len(s) / 2)):
		if (s[i] != s[-i - 1]):
			return False
	return True

r = range(1000, 99, -1)
p = -1
for a in r:
	for b in r:
		m = a*b
		if ispal(m) and m > p:
			print "Answer: %d x %d = %d (%s)" % (a,b,m, ispal(m))
			p = m