[Coco] Project Euler and the Coco

Mark McDougall msmcdoug at iinet.net.au
Sat Nov 15 07:26:14 EST 2008


Arthur Flexser wrote:

> The ascending length requirement means that B must
> take up no more than half of the remaining board, or (1000-A)/2.  

(a^2 + b^2)= c^2
(a^2 + b^2) = (a+b)^2 - 2ab = c^2
therefore, a+b > c
a + b > (1000 - a - b)
2a + 2b > 1000
(a+b) > 500
ie, b > (500-a)

and using Arthur's observation (nice work)

FOR B=500-A TO (1000-A)/2

reduces the number of iterations to find the solution to 10,174 from the 
original 66,174 iterations - a massive 85% reduction!

Regards,

-- 
|              Mark McDougall                | "Electrical Engineers do it
|  <http://members.iinet.net.au/~msmcdoug>   |   with less resistance!"



More information about the Coco mailing list