# [Coco] Project Euler and the Coco

Arthur Flexser flexser at fiu.edu
Sat Nov 15 09:45:22 EST 2008

Mark,

While I agree that b > (500-a), (and nice work to you, too), b must also be
greater than or equal to a. So, for maximum efficiency, the lower bound of b
should be either a or (500-a), whichever is greater. That is, use a as the
lower bound if a > 250, and (500-a) as the lower bound otherwise, to save yet
more iterations when a is between 250 and 333.

Art

On Sat, 15 Nov 2008, Mark McDougall wrote:

> 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!"

>

> --

> Coco mailing list

> Coco at maltedmedia.com

> http://five.pairlist.net/mailman/listinfo/coco

>