[Tutor] largest palindrome number

David Rock david at graniteweb.com
Sat Aug 27 18:32:58 CEST 2011

* surya k <suryak at live.com> [2011-08-27 20:51]:
> here, as the loop goes on, i*j can never become smaller in any case.
> which is why I think it, as long as "PNum" gets a new number, its
> bigger palindrome than the previous.. so, at the end of the loop.
> we'll get largest palindrome number..
> On 8/25/11, Hugo Arts <hugo.yoshi at gmail.com> wrote:
> >
> > When you get a new palindrome, you should make sure it's bigger than
> > the one you already have before you replace the old one. 888888 is the
> > last palindrome you find, but it is not the the biggest. You cannot
> > assume the biggest one will be found last.
> >

As implied by Hugo, What you need to to do is store your largest current
palindrome and as you find a new one, replace the largest current only
if the one you just found is actually larger.  Once you go through the
entire block, the value in your largest current value will actually be
the largest palindrome.

David Rock
david at graniteweb.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/tutor/attachments/20110827/f291b6aa/attachment-0001.pgp>

More information about the Tutor mailing list