aspose file tools*
The moose likes Programming Diversions and the fly likes Right triangles Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Other » Programming Diversions
Bookmark "Right triangles" Watch "Right triangles" New topic
Author

Right triangles

Ryan McGuire
Ranch Hand

Joined: Feb 18, 2005
Posts: 1010
    
    3
More of an exercise than a tricky brain buster.

How may right triangles with all integer side lengths have a side that is 60 units long?

(The hypotenuse is a "side".)
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11406
    
  16

ummm... an infinite? or do you not allow for translations/rotations/reflections?


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Ryan McGuire
Ranch Hand

Joined: Feb 18, 2005
Posts: 1010
    
    3
Originally posted by fred rosenberger:
ummm... an infinite? or do you not allow for translations/rotations/reflections?


Do you REALLY not understand what I'm asking?
Ram Bhakt
Ranch Hand

Joined: Dec 02, 2005
Posts: 145
p**2 + b**2 = 60**2
or
60**2 + b**2 = h**2 ( same as p**2 + 60**2 = h**2 )

where p, b, and h are the lengths of perpendicular, base, and height.

I am not going to solve them but eq 1 will probably have a limited number of solutions (or may be even none) but eq 2 will have unlimited solutions unless there is some mathematical trick involving some property of squares. I guess, one could write a simple program that can use brute force algorithm to start putting values for b as 1 to N and seeing whether sq root of the sum of 60**2 + b**2 is an integer or not.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11406
    
  16

Do you REALLY not understand what I'm asking?

i just enjoy being a pain in the ass sometimess
Jayesh Lalwani
Ranch Hand

Joined: Nov 05, 2004
Posts: 502
I) Assume hypotenuse = 60
a^2 + b^2 = 60^2
a^2 = 60^2 - b^2 = (60+b)(60-b)
a = sqrt[(60+b)(60-b)] where 0 < b <60

So, for a to be an integer 60 + b and 60 - b should be squares of integers

So, let 60 + b = m^2, where m is an integer, and 60< (60+b)<120
Possible values of m are 8, 9 and 10

FOr all possible values of m, find 60 - b such that 60 - b is a square
For m = 8, b= 4, 60 - b = 56, not a square, won't work
For m = 9, b= 21, 60 - b = 39, not a square, won't work
For m = 10, b= 40, 60 - b = 20, not a square, won't work

So, there is no right angle triangle with all integer side lengths have a hypotenuse that is 60 units long

II) Assume side = 60
a ^2 + 60^2 = b^2
a ^2 = b^2 - 60^2 = (b+60)(b-60)where b>60
a = sqrt[(b+60)(b-60)] where b>60
let b+60 = m^2 where m is an integer > 10
b - 60 = n^2 where n is an integer > 0


m^2 - n^2 = 120
(m+n)(m-n) = 120


Let m + n = 2q, m-n = 2r where q and r are integers
Solving we get m = q + r, and n = q-r

so, 4.q.r = 120
q.r = 30 = 2.3.5

So, q = 15, r = 2 OR q = 6, r = 5 OR q = 10, r = 3

So, m = 17, n = 13 OR m = 11, n = 1 OR m= 13, n = 7

So, a = 221 OR a = 11 OR a = 91
b = 229 OR b = 61 OR b = 109

So, there are 3 rt triangles with integer side lengths that have a side that is 60 units long
(221, 60, 229); (11, 60, 61); (91, 60, 109)
Peter van de Riet
Ranch Hand

Joined: Apr 09, 2004
Posts: 112

Originally posted by Jayesh Lalwani:
I) Assume hypotenuse = 60
...
So, there is no right angle triangle with all integer side lengths have a hypotenuse that is 60 units long


The proof on this assumption can't be right:

The famous 3 - 4 - 5 triangle can be multiplied by 12:
36 - 48 - 60 ->
1296 + 2304 = 3600, so there is at least one triangle with hypotenuse 60.


Each number system has exactly 10 different digits.
Peter van de Riet
Ranch Hand

Joined: Apr 09, 2004
Posts: 112

Beside 36-48-60, all other possibilities are:

60-11-61
60-25-65
60-32-68
60-45-75
60-63-87
60-80-100
60-91-109
60-144-156
60-175-185
60-221-229
60-297-303
60-448-452
60-899-901

Originally posted by Ryan McGuire:
How may right triangles with all integer side lengths have a side that is 60 units long?


The answer is 14.
Arjunkumar Shastry
Ranch Hand

Joined: Feb 28, 2005
Posts: 986
Ryan,last year you posed this puzzle.and we solved it.


Namma Suvarna Karnataka
Ryan McGuire
Ranch Hand

Joined: Feb 18, 2005
Posts: 1010
    
    3
Originally posted by Arjunkumar Shastry:
Ryan,last year you posed this puzzle.and we solved it.


Damn!

I just gave someone else grief for posting variations on a previous theme, and then I go and post an exact duplicate of one of my own. However the discussion we've gotten this time around does prove that it's still new to someone.

Yeah that's it... I knew I'd posted it before and I just wanted to see if people would realize it's a previously-solved problem.
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
You could at least replace the number 60 with something much bigger, like 60^4. That way you'd weed out the O(N^2) solutions, as well as invite some additional possible numeric errors if the programmer isn't careful.
[ March 28, 2006: Message edited by: Jim Yingst ]

"I'm not back." - Bill Harding, Twister
Ryan McGuire
Ranch Hand

Joined: Feb 18, 2005
Posts: 1010
    
    3
Originally posted by Jim Yingst:
You could at least replace the number 60 with something much bigger, like 60^4. That way you'd weed out the O(N^2) solutions, as well as invite some additional possible numeric errors if the programmer isn't careful.

[ March 28, 2006: Message edited by: Jim Yingst ]


Ok, how about this:

What number less than or equal to 10,000 is in the most (all-integer) pythagorean triples?
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
9240
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11406
    
  16

9240


i assume at some point proof will be supplied?
Garrett Rowe
Ranch Hand

Joined: Jan 17, 2006
Posts: 1296
Originally posted by "The Mice":
In the absence of any authoritative mathematical proof, always assume the correct answer is 42.


Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
[Fred]: i assume at some point proof will be supplied?

What, don't you trust me?

Oh, very well:
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18651
    
    8

Now you have unearthed a controversy that has been ongoing in the mathematics community since the 1970s: is a computer program a proof?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Right triangles