Re: pythagorean triples exercise

2010-10-24 Thread BartC
"Tim Roberts" wrote in message news:5na7c6dlv0qii3pta58as50lmjcrrtk...@4ax.com... Baba wrote: a^a + b^b = c^c is the condition to satisfy No, it's not. It's a^2 + b^2 = c^2, where a, b, and c are integers. Perhaps you meant a*a + b*b = c*c. Or possibly a**2 + b**2 = c**2 and i need t

Re: pythagorean triples exercise

2010-10-23 Thread Tim Roberts
Baba wrote: > >i need a hint regarding the following exercise question: > >"Write a program that generates all Pythagorean triples whose small >sides are no larger than n. >Try it with n <= 200." > >what is "n" ? i am guessing that it is a way to give a bound to the >triples to be returned but i c

Re: pythagorean triples exercise

2010-10-23 Thread Terry Reedy
On 10/23/2010 3:34 AM, Lawrence D'Oliveiro wrote: In message<8idui6f21...@mid.individual.net>, Peter Pearson wrote: Is it important to let "a" range all the way up to b, instead of stopping at b-1? (tongue in cheek) Makes no difference. :) The difference is that before one writes the restri

Re: pythagorean triples exercise

2010-10-23 Thread Lawrence D'Oliveiro
In message <8idui6f21...@mid.individual.net>, Peter Pearson wrote: > Is it important to let "a" range all the way up to b, instead of > stopping at b-1? (tongue in cheek) Makes no difference. :) -- http://mail.python.org/mailman/listinfo/python-list

Re: pythagorean triples exercise

2010-10-22 Thread Lawrence D'Oliveiro
In message , Baba wrote: > csqrt = math.sqrt(csqrd) > for c in range (1, csqrd): > if c * c == a * a + b * b and math.floor(csqrt) == csqrt: > print (a,b,c) Is there such a term as “bogosearch”? -- http://mail.python.org/mailman/listinfo/python-list

Re: pythagorean triples exercise

2010-10-22 Thread Jeffrey Gaynor
001 ...and there you have your figures. A real proof consists of a bit more, but nobody wants to read it and there is no easy way to notate it in plain text. - Original Message - From: "Mel" To: python-list@python.org Sent: Friday, October 22, 2010 2:20:47 PM Subject: Re: pythag

Re: pythagorean triples exercise

2010-10-22 Thread Mel
Mel wrote: > MRAB wrote: >> On 22/10/2010 13:33, Baba wrote: > >>> only a has an upper limit of 200 >>> >> Really? The quote you gave included "whose small sides are no larger >> than n". Note: "sides", plural. > > Strangely, there does seem to be a limit. Fixing one side at 200, the > largest

Re: pythagorean triples exercise

2010-10-22 Thread Mel
MRAB wrote: > On 22/10/2010 13:33, Baba wrote: >> only a has an upper limit of 200 >> > Really? The quote you gave included "whose small sides are no larger > than n". Note: "sides", plural. Strangely, there does seem to be a limit. Fixing one side at 200, the largest pythagorean triple I have

Re: pythagorean triples exercise

2010-10-22 Thread MRAB
On 22/10/2010 13:33, Baba wrote: On Oct 22, 8:07 am, Dennis Lee Bieber wrote: On Thu, 21 Oct 2010 03:51:07 -0700 (PDT), Baba declaimed the following in gmane.comp.python.general: Hi everyone i need a hint regarding the following exercise question: "Write a program that generates all Pyt

Re: pythagorean triples exercise

2010-10-22 Thread Peter Pearson
On Fri, 22 Oct 2010 01:35:11 -0400, Terry Reedy wrote: > On 10/21/2010 7:55 PM, Baba wrote: > >> the bit i'm having difficulties with in constructing my loops is: >> "whose small sides are no larger than n" > > from math import sqrt > > def py_trips(n): >for b in range(4,n+1): > for a in

Re: pythagorean triples exercise

2010-10-22 Thread Baba
On Oct 22, 6:35 am, Terry Reedy wrote: > On 10/21/2010 7:55 PM, Baba wrote: > > > the bit i'm having difficulties with in constructing my loops is: > > "whose small sides are no larger than n" > > from math import sqrt > > def py_trips(n): >    for b in range(4,n+1): >      for a in range(3,b+1):

Re: pythagorean triples exercise

2010-10-22 Thread Baba
On Oct 22, 6:35 am, Terry Reedy wrote: > On 10/21/2010 7:55 PM, Baba wrote: > > > the bit i'm having difficulties with in constructing my loops is: > > "whose small sides are no larger than n" > > from math import sqrt > > def py_trips(n): >    for b in range(4,n+1): >      for a in range(3,b+1):

Re: pythagorean triples exercise

2010-10-22 Thread Baba
On Oct 22, 8:07 am, Dennis Lee Bieber wrote: > On Thu, 21 Oct 2010 03:51:07 -0700 (PDT), Baba > declaimed the following in gmane.comp.python.general: > > > Hi everyone > > > i need a hint regarding the following exercise question: > > > "Write a program that generates all Pythagorean triples whos

Re: pythagorean triples exercise

2010-10-21 Thread Terry Reedy
On 10/21/2010 7:55 PM, Baba wrote: the bit i'm having difficulties with in constructing my loops is: "whose small sides are no larger than n" from math import sqrt def py_trips(n): for b in range(4,n+1): for a in range(3,b+1): cf = sqrt(a*a+b*b) c = int(cf) if c == cf

Re: pythagorean triples exercise

2010-10-21 Thread Baba
On Oct 21, 10:18 pm, Terry Reedy wrote: > On 10/21/2010 6:55 AM, Baba wrote: > > > Hi everyone > > > i need a hint regarding the following exercise question: > > > "Write a program that generates all Pythagorean triples whose small > > sides are no larger than n. > > This is not well worded. I tak

Re: pythagorean triples exercise

2010-10-21 Thread Terry Reedy
On 10/21/2010 6:55 AM, Baba wrote: Hi everyone i need a hint regarding the following exercise question: "Write a program that generates all Pythagorean triples whose small sides are no larger than n. This is not well worded. I take 'small sides' (plural) to mean the two smaller, non-hypotenu

Re: pythagorean triples exercise

2010-10-21 Thread Jeffrey Gaynor
What you want is to realize that all integer Pythagorean triples can be generated by a pair of integers, (i,j), j < i. The values are just (* = multiply, ^ = exponentiation) a = 2*i*j b = i^2 - j^2 c = i^2 + j^2 (hypotenuse) So yes indeed a^2 + b^2 = c^2. This is a very ancient result, btw and

Re: pythagorean triples exercise

2010-10-21 Thread Alex Hall
On 10/21/10, Baba wrote: > Hi everyone > > i need a hint regarding the following exercise question: > > "Write a program that generates all Pythagorean triples whose small > sides are no larger than n. > Try it with n <= 200." > > what is "n" ? i am guessing that it is a way to give a bound to the