Problem 4: Largest palindrome product
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.
3位数的话,就从999开始,为了减少遍历次数,就先从999-900,如果没有条件满足,再放大这个范围
l = []
for i in range(999, 900, -1):
for j in range(999, 900, -1):
n = str(i * j)
if n == n[::-1]:
l.append(int(n))
print(max(l))
执行结果:906609
Problem 4: Largest palindrome product的更多相关文章
- 【欧拉计划4】Largest palindrome product
欢迎访问我的新博客:http://www.milkcu.com/blog/ 原文地址:http://www.milkcu.com/blog/archives/1371281760.html 原创:[欧 ...
- (Problem 4)Largest palindrome product
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2 ...
- Largest palindrome product
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2 ...
- 欧拉计划之Largest palindrome product
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2 ...
- [LeetCode] Largest Palindrome Product 最大回文串乘积
Find the largest palindrome made from the product of two n-digit numbers. Since the result could be ...
- 【easy】479. Largest Palindrome Product
Find the largest palindrome made from the product of two n-digit numbers Since the result could be v ...
- [Swift]LeetCode479. 最大回文数乘积 | Largest Palindrome Product
Find the largest palindrome made from the product of two n-digit numbers. Since the result could be ...
- LeetCode Largest Palindrome Product
原题链接在这里:https://leetcode.com/problems/largest-palindrome-product/description/ 题目: Find the largest p ...
- 【LeetCode】479. Largest Palindrome Product 解题报告(Python & C++)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 日期 题目地址:https://leetcode.c ...
随机推荐
- dp入门之01背包问题
...通过暴力手推得到的一点点感觉 动态规划是相对于贪心算法的一种取得最优解的算法,通过对每一步的取舍判断从 0 推到所拥有的第 n 件物品,每次判断可以列写出状态转移方程,通过记忆化相对暴力地取得最 ...
- laravel基础知识学习总结(路由、中间件、控制器)
路由: 路由:是将信息从源地址传递到目的地得角色 Route::get('/test',function(){ }); //分号不能丢 报错信息MethodNotAllowedHttpExcept ...
- Windows 7环境下网站性能测试小工具 Apache Bench 和 Webbench使用和下载
1.简要说明: Apache Bench 是Apache的网站性能测试小程序,Windows平台下的程序名简称ab.exe,要想获得这个80k的可执行程序,用户需要下载整个Apache Httpd软件 ...
- MongoDB数据查询 --MongoDB
1.插入测试数据 use flower db.goods.insert({'goods_name':'Hyacinth',price:10,num:800}) db.goods.insert({goo ...
- LNMP的搭建
一.下载安装MySQL 1.1:下载地址:https://dev.mysql.com/downloads/mysql/ 1.2:安装后 1.2.1:解压:tar -xf mysql-8.0.15-li ...
- Django中ORM介绍和字段及字段参数
Object Relational Mapping(ORM) 1 ORM介绍 1.1 ORM概念 对象关系映射(Object Relational Mapping,简称ORM)模式是一种为了解决面向对 ...
- 调用 CURL 使用正则抓取信息
Class MyCurl{ protected $_pdo; //构造方法 链接数据库 public function __construct(){ $this->_pdo ...
- WinForm界面设计优化过程
以在做的项目为例,记录一下界面美化过程中遇到的问题,由于项目是先做出来之后,又请美工进行稍微调整设计界面,所以会又些限制 1. TabControl的问题----在添加了背景图片后,TabContro ...
- 电磁波、无线电、802、WLAN及WiFi的区别与联系
一.电磁波.无线电.WLAN和WiFi的关系 电磁波 > 无线电 [+ 可见光] > WLAN [+ 电话 ]> WiFi [+蓝牙] 参考:https://zh.wikipedia ...
- 简单的epub制作
最近在无聊看轻小说的时候,找到了一套叫<白银龙王的摇篮>的书. 台版一共出了6卷,并且wenku8都已经录入了,但是轻国的epub录入只有2卷. 我寻思着做epub也不是什么难事,就稍微百 ...