aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xchallenge-136/feng-chang/raku/ch-1.raku9
-rwxr-xr-xchallenge-136/feng-chang/raku/ch-2.raku11
2 files changed, 20 insertions, 0 deletions
diff --git a/challenge-136/feng-chang/raku/ch-1.raku b/challenge-136/feng-chang/raku/ch-1.raku
new file mode 100755
index 0000000000..c1cc9c1c7e
--- /dev/null
+++ b/challenge-136/feng-chang/raku/ch-1.raku
@@ -0,0 +1,9 @@
+#!/bin/env raku
+
+multi sub is-two-friendly(0) { True }
+multi sub is-two-friendly(2) { True }
+multi sub is-two-friendly(UInt:D \n) { n %% 2 and is-two-friendly(n div 2) }
+
+sub MAIN(UInt:D \m, UInt:D \n) {
+ put +is-two-friendly(m gcd n);
+}
diff --git a/challenge-136/feng-chang/raku/ch-2.raku b/challenge-136/feng-chang/raku/ch-2.raku
new file mode 100755
index 0000000000..418370329a
--- /dev/null
+++ b/challenge-136/feng-chang/raku/ch-2.raku
@@ -0,0 +1,11 @@
+#!/bin/env raku
+
+my @fibo = 1, 2, * + * ... *;
+
+sub fibo-floor(UInt:D \n --> UInt:D) {
+ (^n).grep({ @fibo[$_] ≤ n }).max
+}
+
+sub MAIN(UInt:D \n) {
+ put @fibo[0 .. fibo-floor(n)].combinations.grep(*.sum == n).elems;
+}