aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <Mohammad.Anwar@yahoo.com>2025-01-27 00:16:28 +0000
committerGitHub <noreply@github.com>2025-01-27 00:16:28 +0000
commitb600a0ac3963dbc287c58cac690e27a831a99c05 (patch)
treea9dd152e18b48b19ab160f4fe191d5cfab2f4c0a
parent92bb6e8cd849038dcb7cfca69fab6413225cd19a (diff)
parent20b20ff58341c95168c22f2cd6a24bfb04297748 (diff)
downloadperlweeklychallenge-club-b600a0ac3963dbc287c58cac690e27a831a99c05.tar.gz
perlweeklychallenge-club-b600a0ac3963dbc287c58cac690e27a831a99c05.tar.bz2
perlweeklychallenge-club-b600a0ac3963dbc287c58cac690e27a831a99c05.zip
Merge pull request #11491 from wambash/challenge-week-305
solutions week 305
-rw-r--r--challenge-305/wambash/raku/ch-1.raku24
-rw-r--r--challenge-305/wambash/raku/ch-2.raku23
2 files changed, 47 insertions, 0 deletions
diff --git a/challenge-305/wambash/raku/ch-1.raku b/challenge-305/wambash/raku/ch-1.raku
new file mode 100644
index 0000000000..f56998526a
--- /dev/null
+++ b/challenge-305/wambash/raku/ch-1.raku
@@ -0,0 +1,24 @@
+#!/usr/bin/env raku
+
+sub binary-prefix (+binary) {
+ binary
+ andthen [\~] binary
+ andthen .map: { :2(.Str).is-prime }
+}
+
+multi MAIN (Bool :test($)!) {
+ use Test;
+ is binary-prefix(1,0,1), (False,True,True);
+ is binary-prefix(1,1,0), (False,True,False);
+ is binary-prefix(1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1), (
+ False, True, True, False, False,
+ True, False, False, False, False,
+ False, False, False, False, False,
+ False, False, False, False, True
+ );
+ done-testing;
+}
+
+multi MAIN (+binary) {
+ put binary-prefix binary
+}
diff --git a/challenge-305/wambash/raku/ch-2.raku b/challenge-305/wambash/raku/ch-2.raku
new file mode 100644
index 0000000000..1f7df7fbf9
--- /dev/null
+++ b/challenge-305/wambash/raku/ch-2.raku
@@ -0,0 +1,23 @@
+#!/usr/bin/env raku
+
+sub alien-dictionary (+words,:@alien) {
+ my %alphabet = @alien.antipairs;
+ words.sort: { %alphabet{ .comb } }
+}
+
+multi MAIN (Bool :test($)!) {
+ use Test;
+ is alien-dictionary(
+ <perl python raku>,
+ :alien<h l a b y d e f g i r k m n o p q j s t u v w x c z>
+ ), <raku python perl>;
+ is alien-dictionary(
+ <the weekly challenge>,
+ :alien<c o r l d a b t e f g h i j k m n p q s w u v x y z>
+ ), <challenge the weekly>;
+ done-testing;
+}
+
+multi MAIN (+words,:$alien) {
+ put alien-dictionary words,:alien($alien.comb)
+}