zoukankan      html  css  js  c++  java
  • Problem 4

    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)
    Resistance is Futile!
  • 相关阅读:
    django 2.0 path
    Django
    ORM
    Django简介
    web框架
    HTTP协议
    web应用
    索引
    pyMysql模块
    视图、触发器、存储过程、函数
  • 原文地址:https://www.cnblogs.com/noonjuan/p/10957194.html
Copyright © 2011-2022 走看看