Problem 4
# 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.
找到两个三位数数字相乘能得到的最大的回文数字
"""
palindroms = {}
for x in range(100, 1000):
for y in range(100, 1000):
num = str(x * y)
length = len(num)
mid = length // 2
formar = num[:mid]
latter = num[mid:][::-1]
if not length % 2 == 0:
latter = num[mid+1:][::-1]
if formar == latter:
value = str(x) + '*' + str(y)
palindroms[int(num)] = value
print(palindroms)
max_key = max(palindroms)
max_value = palindroms[max_key]
print(max_key, '==>', max_value)