Contribution for Puzzlet #064

From: Denis Borris [borrisd@ca.inter.net]

You can solve that "type" by looping only one variable.

Let the sides be a,b and c (c = hypotenuse)

a + b + c + ab/2 = 280

a + b + sqrt(a^2 + b^2) + ab/2 = 280

2sqrt(a^2 + b^2) = 560 - 2a - 2b - ab

square both sides leads to:

a^2(b^2 + 4b) + a(4b^2 - 1112b - 2240) - 2240b + 313600 = 0

let x = b^2 + 4b, y = 4b^2 - 1112b - 2240, z = 313600 - 2240b; then:

xa^2 + ya + z = 0

a = [-y +- sqrt(y^2 - 4xz)] / (2x)

so: loop b, calculate a, c = sqrt(a^2 + b^2)

Not too important to save time here of course (with 280 as total)

but would be if the 280 was a 20 digit (or more) number!

Thanks for this. I hadn't thought of doing it this way (as the actress said to the bishop). As you say, an important approach for larger numbers.

Dave.

Site
design/maintenance:
Dave Ellis |
E-mail
me! |
Last Updated: February
22nd, 2004. |