wu :: forums
« wu :: forums - Right angle Triangle Problem »

Welcome, Guest. Please Login or Register.
May 19th, 2024, 11:49am

RIDDLES SITE WRITE MATH! Home Home Help Help Search Search Members Members Login Login Register Register
   wu :: forums
   riddles
   medium
(Moderators: william wu, SMQ, Eigenray, towr, ThudnBlunder, Grimbal, Icarus)
   Right angle Triangle Problem
« Previous topic | Next topic »
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print
   Author  Topic: Right angle Triangle Problem  (Read 3245 times)
sumtatt
Newbie
*





   
Email

Gender: male
Posts: 23
Right angle Triangle Problem  
« on: Jan 10th, 2012, 5:44am »
Quote Quote Modify Modify

There is array of some number of integers, find the combination of all number which make the right angle triangle.
i.e  
int a[9] = (1,2,3,4,5,6,7,8,10);  
 
Answer should be (3,4,5) (6,8,10)
 
Kindly provide the link if it has already asked.
« Last Edit: Jan 10th, 2012, 8:12pm by sumtatt » IP Logged
Grimbal
wu::riddles Moderator
Uberpuzzler
*****






   


Gender: male
Posts: 7527
Re: Rectangle Triangle Problem  
« Reply #1 on: Jan 10th, 2012, 6:49am »
Quote Quote Modify Modify

I don't understand what you mean by "make the rectangle triangle.
Also, in your output there is a 5, which is not in the input.  Is that normal?
IP Logged
towr
wu::riddles Moderator
Uberpuzzler
*****



Some people are average, some are just mean.

   


Gender: male
Posts: 13730
Re: Rectangle Triangle Problem  
« Reply #2 on: Jan 10th, 2012, 8:37am »
Quote Quote Modify Modify

I think he means Pythagorean triangles.
IP Logged

Wikipedia, Google, Mathworld, Integer sequence DB
Grimbal
wu::riddles Moderator
Uberpuzzler
*****






   


Gender: male
Posts: 7527
Re: Rectangle Triangle Problem  
« Reply #3 on: Jan 10th, 2012, 9:46am »
Quote Quote Modify Modify

Makes sense.
 
One method would be to take every pair in the set as the first 2 numbers and do a binary search for the third.
 
Another method would be to generate all triples up to the maximum number in the set and check each triple if it's in the set.
 
The first method would be best if the numbers are few and very large.  The second if the numbers are many and relatively small.
« Last Edit: Jan 10th, 2012, 9:49am by Grimbal » IP Logged
sumtatt
Newbie
*





   
Email

Gender: male
Posts: 23
Re: Rectangle Triangle Problem  
« Reply #4 on: Jan 10th, 2012, 11:29am »
Quote Quote Modify Modify

Thanks!
 
What will be the complexity for the same.
 
Can you write the algorithm please?
 
IP Logged
sumtatt
Newbie
*





   
Email

Gender: male
Posts: 23
Re: Rectangle Triangle Problem  
« Reply #5 on: Jan 10th, 2012, 11:32am »
Quote Quote Modify Modify

Sorry Grimbal.. I have corrected the question.
I think i have lost my mind when i was writing.
My apologies.
IP Logged
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print

« Previous topic | Next topic »

Powered by YaBB 1 Gold - SP 1.4!
Forum software copyright © 2000-2004 Yet another Bulletin Board