* surya k <sur...@live.com> [2011-08-27 20:51]: <snip> > > 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.yo...@gmail.com> wrote: <snip> > > > > 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 da...@graniteweb.com
pgpqe98kqh5z1.pgp
Description: PGP signature
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor