aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-082/ash/raku/ch-1.raku16
-rw-r--r--challenge-082/ash/raku/ch-2.raku23
2 files changed, 39 insertions, 0 deletions
diff --git a/challenge-082/ash/raku/ch-1.raku b/challenge-082/ash/raku/ch-1.raku
new file mode 100644
index 0000000000..f6aaef2abe
--- /dev/null
+++ b/challenge-082/ash/raku/ch-1.raku
@@ -0,0 +1,16 @@
+#!/usr/bin/env raku
+#
+# Task 1 from
+# https://perlweeklychallenge.org/blog/perl-weekly-challenge-082/
+
+# Test runs:
+# $ raku ch-1.raku 12 18
+# (1 2 3 6)
+# $ raku ch-1.raku 100 500
+# (1 2 4 5 10 20 25 50 100)
+# $ raku ch-1.raku 18 23
+# (1)
+
+my ($a, $b) = @*ARGS;
+
+say ((1 .. ($a max $b)).grep: $a %% *).grep: $b %% *;
diff --git a/challenge-082/ash/raku/ch-2.raku b/challenge-082/ash/raku/ch-2.raku
new file mode 100644
index 0000000000..0c95ea66fb
--- /dev/null
+++ b/challenge-082/ash/raku/ch-2.raku
@@ -0,0 +1,23 @@
+#!/usr/bin/env raku
+#
+# Task 2 from
+# https://perlweeklychallenge.org/blog/perl-weekly-challenge-082/
+
+unit sub MAIN(Str $a, Str $b, Str $c);
+
+my @parts;
+for ^$a.chars -> $pos {
+ say 1 and return if $c eq $a.substr(0, $pos) ~ $b ~ $a.substr($pos);
+}
+
+# Not sure if the below tests agree with the idea of the task.
+
+say 2 and return if $c eq $a ~ $b;
+
+for ^$b.chars -> $pos {
+ say 3 and return if $c eq $b.substr(0, $pos) ~ $a ~ $b.substr($pos);
+}
+
+say 4 and return if $c eq $b ~ $a;
+
+say 0;