aboutsummaryrefslogtreecommitdiff
path: root/challenge-102
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-102')
-rwxr-xr-xchallenge-102/feng-chang/raku/ch-1.raku17
-rwxr-xr-xchallenge-102/feng-chang/raku/ch-2.raku15
2 files changed, 32 insertions, 0 deletions
diff --git a/challenge-102/feng-chang/raku/ch-1.raku b/challenge-102/feng-chang/raku/ch-1.raku
new file mode 100755
index 0000000000..463aa8f413
--- /dev/null
+++ b/challenge-102/feng-chang/raku/ch-1.raku
@@ -0,0 +1,17 @@
+#!/bin/env raku
+
+sub is-square(UInt:D \N --> Bool:D) {
+ my UInt $n = N.sqrt.UInt;
+ N == $n * $n;
+}
+
+sub MAIN(UInt:D \N) {
+ my UInt $min = ('1' ~ '0' x N-1).UInt;
+ my UInt $max = ('9' x N).UInt;
+ for $min..$max -> $m {
+ my UInt $n = $m.flip.UInt;
+ next if $n > $m;
+
+ put $m if is-square($m + $n) and is-square($m - $n);
+ }
+}
diff --git a/challenge-102/feng-chang/raku/ch-2.raku b/challenge-102/feng-chang/raku/ch-2.raku
new file mode 100755
index 0000000000..394fede9ae
--- /dev/null
+++ b/challenge-102/feng-chang/raku/ch-2.raku
@@ -0,0 +1,15 @@
+#!/bin/env raku
+
+sub MAIN(UInt:D \N) {
+ my Str:D $s = '#';
+ my UInt:D $pos = N;
+
+ while $s.chars < N {
+ $s = $pos ~ $s;
+ $pos = N - $s.chars;
+
+ $s = '#' ~ $s if $s.chars < N;
+ }
+
+ put $s;
+}