How's the run time? I think yours is Python 2?
Here's mine in Python 3 :) It's a bit more complicated because I try to write them more flexible. Like how this problem shows 2 digit numbers as an example and 3 for the actual problem, so I wrote it to take the number of digits per number as an input
min, max, temp, pal = '1', '', 0, 0
for _ in range (1,digits):
min += '0'
for _ in range (0,digits):
max += '9'
min = int(min)-1
max = int(max)
start = time.time()
for num1 in range (max,min,-1):
for num2 in range (num1,min,-1):
temp = num1 * num2
if temp < pal:
if str(temp) == "".join(reversed(str(temp))):
pal = temp
end = time.time()
print(pal, end=' ')
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.