Closed tsalada closed 1 year ago
Good one. Thanks for the report! We'll check it out.
Perhaps change the final line from:
say [*] .list for gather triples(1000);
to:
.say for gather triples(1000);
The solution proposed by ngaywood works on my machine.
In the companion script, prob009-gerdr-feeds.pl, commenting out the line
==> map -> @triple { [*] @triple } \
would yield the correct answer.
Examples prob009-gerdr.pl and gerdr-feeds.pl give an incorrect answer.
The object is to find three numbers, a < b < c, such that (1) a 2 + b 2 = c * 2; and, (2) a + b + c = 1000. The correct answer is 200 375 and 425, but each of the above mentioned scripts gives 31875000 (which is 200 375 * 425).
The attached file (adapted from prob009-gerdr.pl) gives the correct answer (thus indicating that the problem stems from using gather ... take). find_Pythagorean_Triplet.txt
Edit: Full code in the above link is :