`
jonson
  • 浏览: 168583 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

Problem four.

阅读更多

预备知识:

palindromic number 回文数字。如:9009.正序与逆序所获取的字符串是一致的。

 

Question:

 

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.

 

在python中如何进行:

1.数值转化成字符串。

函数                      描述
int(x [,base ])         将x转换为一个整数
long(x [,base ])        将x转换为一个长整数
float(x )               将x转换到一个浮点数
complex(real [,imag ])  创建一个复数
str(x )                 将对象 x 转换为字符串
repr(x )                将对象 x 转换为表达式字符串
eval(str )              用来计算在字符串中的有效Python表达式,并返回一个对象
tuple(s )               将序列 s 转换为一个元组
list(s )                将序列 s 转换为一个列表
chr(x )                 将一个整数转换为一个字符
unichr(x )              将一个整数转换为Unicode字符
ord(x )                 将一个字符转换为它的整数值
hex(x )                 将一个整数转换为一个十六进制字符串
oct(x )                 将一个整数转换为一个八进制字符串
 

 

2.如何对字符串进行 reverse。

‘abc'[::-1] 返回cba

 

 

 

 

 

 

 

 

my solution:

 

def findBpalindromic():
  """ find the biggest palindromic number which is product of two 3-digit number
  """
  [x,y,result,rst,rstx,rsty] = [1000,1000,0,0,0,0]
  for i in range(100,x):
    for j in range(100,y):
      result = i * j
      rvs = str(result)[::-1]
      if rvs == str(result):
        if rst < result :
          rst = rst1
          rstx = i
          rsty = j
  print rst,rstx,rsty
 

 

1
1
分享到:
评论

相关推荐

    Artificial Intelligence and Problem Solving

    summAry Of evenTs ThAT LeD TO The DefiniTiOn AnD sOLuTiOn TO The fOur cOLOr PrOBLem......Page 278 sAmPLe Of cODe frOm The PrOOf......Page 280 references......Page 282 15 Cryptography......Page 283 ...

    Computer-Based.Problem.Solving.Process

    concepts and methodology and develops a framework for software creation that supports domain-oriented problem solving process adapting Polya's four steps methodology for mathematical problem solving:...

    Algorithmic Problem Solving

    Algorithmic Problem Solving By 作者: Roland Backhouse ISBN-10 书号: 0470684534 ISBN-13 书号: 9780470684535 Edition 版本: 1 出版日期: 2011-10-24 pages 页数: 432 An entertaining and captivating way to ...

    knight problem问题c++代码

    ### Knight Problem 使用 C++ 和 A* 算法解析 #### 一、Knight Problem 介绍 Knight Problem(骑士问题)通常是指在一个国际象棋棋盘上寻找一条路径,使得一个骑士能够从起始位置到达目标位置。由于骑士的移动方式...

    Text Mining: Classification, Clustering, and Applications

    3.2 Collective Classification: Notation and Problem Definition . . 53 3.3 Approximate Inference Algorithms for Approaches Based on Local Conditional Classifiers . . . . . . . . . . . . . . . . . . . ...

    The Notorious Four-Color Problem-计算机科学

    GraphsThe Solution of the Four-Color Problem More About Coloring GraphsThe Notorious Four-Color ProblemProf. Jeremy L. Martin Department of MathematicsUniversity of KansasKU Mini College June 5, 20131...

    矩阵学习资源

    Contents Preface . . . . . . . . ....1 Introduction ....2 Sets ....3 Matrices: addition and multiplication ....4 The transpose of a matrix ....5 Square matrices ....6 Linear forms and quadratic forms ....

    Matrix Differential Calculus with Applications in Statistics and Econometrics

    Contents Preface . . . . . . . . ....1Introduction ....2Sets ....3Matrices: addition and multiplication ....4The transpose of a matrix ....5Square matrices ....6Linear forms and quadratic forms ....7The rank of a matrix ....

    a project model for the FreeBSD Project.7z

    Number of committers has been determined by going through CVS logs from January 1st, 2004 to December 31st, 2004 and contributors by going through the list of contributions and problem reports. ...

    Beckhoff EP92X4模块用户手册

    The EP9214-0023 enables connection of four power supply branches. In each branch the current consumption for the control ...During startup consumers with large capacities can be added without problem.

    江苏省张家港市第二中学2020届九年级英语下学期期中试题(无答案).doc

    four-fifths`涉及到了数量表达和分数表达。`The number of`指“...的数量”,是名词性短语,谓语动词用单数;分数表达时,分子用基数词,分母用序数词,当分子大于1时,分母后加-s。 2. **交际用语与语境理解**:`...

    APMCM竞赛论文模板.docx

    - **The Description of the Problem**:问题描述,对竞赛题目进行深入分析,分为多个子问题逐一阐述,如"Problem Analysis of Problem One"至"Problem Analysis of Problem Four"。 - **Assumptions and ...

    HPL: Vol. IV: Functional and Logic Programming Languages

    6.4.5. The Transitive Closure Problem 6.4.6. Tail Recursion Optimization 6.4.7. First Argument Indexing 6.4.8. Reading Clauses from the Terminal 6.4.9. Using the Dash in a Symbol 6.5. Examples ...

    计算机网络第六版答案

    Computer Networking: A Top-Down Approach, 6th Edition Solutions to Review Questions and Problems Version Date: May 2012 ...This document contains the solutions to review questions ...Problem 1 There...

    xmlpattern

    We present four patterns that can be utilized to achieve a successful solution in that endeavor. Each individual pattern is a way of solving part of this general problem. In these patterns XML proves ...

    Graph Embedding Survey

    Finally, we summarize the applications that graph embedding enables and suggest four promising future research directions in terms of computation efficiency, problem settings, techniques and ...

    Problem solving ability of disadvantaged elementary school children under four testing formats: A replicated experiment

    Problem solving ability of disadvantaged elementary school children under four testing formats: A replicated experiment PROBLEM SOLVING ABILITY OF DISADVANTAGED ELERIENTARY SCHOOL CHILDREN UNDER ...

    英语四级必备句子100

    1. 数据引用和事实陈述:例如"According to a recent survey, four million people die each year from diseases linked to smoking." 这样的句子在写作中能增加论据的说服力,展示了对当前问题的了解和研究。...

    高中英语人版必修二知识点总结.doc

    - every four years 例如:The Olympic Games are held every four years. - take part in 例如:Everyone is encouraged to take part in sports activities. 通过熟练掌握这些知识点,学生将能够更有效地理解...

    Discrete Volterra Series and Nonlinear Echo Cancellation

    The discrete Volterra series holds particular value in the analysis of nonlinear systems in telecommunications. However, most books on the ... Would give it three and a half stars -rounded up to four.

Global site tag (gtag.js) - Google Analytics