Skip to content

Commit ca200a0

Browse files
committed
[euler/prob009] add version using feed operators
1 parent 00f5048 commit ca200a0

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

euler/prob009-gerdr-feeds.pl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
use v6;
2+
3+
constant N = 1000;
4+
5+
# possible range of a
6+
1..Int((1 - sqrt(0.5)) * N)
7+
8+
# compute numerator and denominator of closed expression for b
9+
==> map -> \a { [ a, N * (N - 2 * a), 2 * (N - a) ] }
10+
11+
# check if closed expression yields an integer
12+
==> grep -> [ \a, \u, \v ] { u %% v }
13+
14+
# compute b and c
15+
==> map -> [ \a, \u, \v ] { my \b = u div v; [ a, b, N - a - b ] }
16+
17+
# compute product
18+
==> map -> @triple { [*] @triple }
19+
20+
# print result
21+
==> say;

0 commit comments

Comments
 (0)