[Tutor] where I am going wrong?

surya k suryak at live.com
Wed Dec 14 16:32:55 CET 2011




----------------------------------------
> From: suryak at live.com
> To: waynejwerner at gmail.com
> CC: tutor at python.org
> Subject: RE: [Tutor] where I am going wrong?
> Date: Wed, 14 Dec 2011 19:59:24 +0530
>
>
>
>
> ________________________________
> > From: waynejwerner at gmail.com
> > Date: Wed, 14 Dec 2011 08:25:53 -0600
> > Subject: Re: [Tutor] where I am going wrong?
> > To: suryak at live.com
> > CC: tutor at python.org
> >
> > On Wed, Dec 14, 2011 at 8:13 AM, surya k
> > <suryak at live.com<mailto:suryak at live.com>> wrote:
> >
> > This is a project Euler
> > puzzle. http://projecteuler.net/problem=30<http://projecteuler.net/problem%3d30>
> > I applied brute force way and here is my code
> > k=0for p in range(1,10): for q in range(0,10): for r in
> > range(0,10): for s in range(0,10): for t in
> > range(0,10): n = (p*10000)+ (q*1000) + (r*100) + (s*10)
> > + (t*1) if n == \ p**5 + q**5 +
> > r**5 + s**5 + t**5: print n
> > k+=nprint k
> > My answer: 240559
> > But its showing the answer as wrong!!.
> > I used the same method on the example puzzle and it worked.
> >
> > Your email client broke the formatting - you should probably use
> > plain-text or a pastebin.
> >
> > -Wayne


This is a project Euler puzzle. http://projecteuler.net/problem=30I applied brute force way and here is my codek=0for p in range(1,10):        for q in range(0,10):                 for r in range(0,10):                            for s in range(0,10):                                       for t in range(0,10):                                             n = (p*10000)+ (q*1000) + (r*100) + (s*10) + (t*1)                                                    if n ==  p**5 + q**5 + r**5 + s**5 + t**5:                                                                                             k+=n
print kMy answer: 240559But its showing the answer as wrong!!.I used the same method on the example puzzle and it worked. 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20111214/ee152376/attachment-0001.html>


More information about the Tutor mailing list