/dev/Chiheb-Nexus

Solution de Projecteuler.net: Problème 4 (Python)

# Project Euler: Problem 4
#
# A palindromic number reads the same both ways. 
# The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.
#
# Find the largest palindrome made from the product of two 3-digit numbers.
#
################################
# Solution: 906609
# Best time: 0.4428544044494629
################################

from time import time

def get_palindromic(m):
    p = []
    for k in range(m):
        for j in range(m):
            a = str(k*j)
            b = a[::-1]
            if a == b:
                p.append(int(a))
    return max(p)

start = time()
max_palandromic = get_palindromic(1000)
elapsed = time() - start
print("Solution: {0} \t Time elapsed: {1}".format(max_palandromic, elapsed))