aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHumberto Massa <humbertomassa@gmail.com>2024-02-03 11:40:32 -0300
committerHumberto Massa <humbertomassa@gmail.com>2024-02-03 11:40:32 -0300
commit75e8f713b9b764ede3cb2a5f720c839b269f2040 (patch)
tree7bb15173b5c4eb30cdb8c36c339c7ee3b1e2b0a2
parent82326e598e6adccf727d7c9f996280885de2edb4 (diff)
downloadperlweeklychallenge-club-75e8f713b9b764ede3cb2a5f720c839b269f2040.tar.gz
perlweeklychallenge-club-75e8f713b9b764ede3cb2a5f720c839b269f2040.tar.bz2
perlweeklychallenge-club-75e8f713b9b764ede3cb2a5f720c839b269f2040.zip
Trying to recuperate from dengue fever
-rw-r--r--challenge-254/massa/raku/ch-1.raku68
-rw-r--r--challenge-254/massa/raku/ch-2.raku67
2 files changed, 135 insertions, 0 deletions
diff --git a/challenge-254/massa/raku/ch-1.raku b/challenge-254/massa/raku/ch-1.raku
new file mode 100644
index 0000000000..2cd6a3f23f
--- /dev/null
+++ b/challenge-254/massa/raku/ch-1.raku
@@ -0,0 +1,68 @@
+#! /usr/bin/env raku
+
+# Perl Weekly Challenge
+# © 2023 Shimon Bollinger. All rights reserved.
+# Last modified: Mon 15 May 2023 09:17:32 PM EDT
+# Version 0.0.1
+
+=begin pod
+=TITLE
+=head2 Task 1: Three Power
+
+=SUBTITLE
+=head2 Submitted by massa
+
+=CHALLENGE
+=head2
+
+You are given a positive integer, $n.
+
+Write a script to return true if the given integer is a power of three
+otherwise return false.
+
+=head3 Example 1:
+
+ Input: $n = 27
+ Output: true
+
+ 27 = 3 ^ 3
+
+=head3 Example 2:
+
+ Input: $n = 0
+ Output: true
+
+ 0 = 0 ^ 3
+
+=head3 Example 3:
+
+ Input: $n = 6
+ Output: false
+
+=SOLUTION
+
+=end pod
+
+# always use the latest version of Raku
+use v6.*;
+
+sub SOLUTION($n) {
+ (^∞).map(3 ** *).first(* >= $n) == $n
+}
+
+multi MAIN (Bool :$test!) {
+ use Testo;
+
+ my @tests =
+ %{ input => 27,
+ output => True },
+ %{ input => 0,
+ output => False },
+ %{ input => 6,
+ output => False },
+ ;
+
+ .<input>.&SOLUTION.&is-eqv: .<output>, .<text> for @tests
+} # end of multi MAIN (Bool :$test!)
+
+
diff --git a/challenge-254/massa/raku/ch-2.raku b/challenge-254/massa/raku/ch-2.raku
new file mode 100644
index 0000000000..0aaf2ad34c
--- /dev/null
+++ b/challenge-254/massa/raku/ch-2.raku
@@ -0,0 +1,67 @@
+#! /usr/bin/env raku
+
+# Perl Weekly Challenge
+# © 2023 Shimon Bollinger. All rights reserved.
+# Last modified: Mon 15 May 2023 09:17:32 PM EDT
+# Version 0.0.1
+
+=begin pod
+=TITLE
+=head2 Task 2: Reverse Vowels
+
+=SUBTITLE
+=head2 Submitted by massa
+
+=CHALLENGE
+=head2
+
+You are given a string, $s.
+
+Write a script to reverse all the vowels (a, e, i, o, u) in the given string.
+
+=head3 Example 1:
+
+ Input => "Raku"
+ Output => "Ruka"
+
+=head3 Example 2:
+
+ Input => "Perl"
+ Output => "Perl"
+
+=head3 Example 3:
+
+ Input => "Julia"
+ Output => "Jaliu"
+
+=head3 Example 4:
+
+ Input => "Uiua"
+ Output => "Auiu"
+
+=SOLUTION
+
+=end pod
+
+# always use the latest version of Raku
+use v6.*;
+
+sub SOLUTION($_) {
+ my @reversed-vowels = .lc.flip.comb.grep: /<[aeiou]>/;
+ .lc.comb.map({ /<[aeiou]>/ ?? @reversed-vowels.shift !! $_ }).join.samecase($_)
+}
+
+multi MAIN (Bool :$test!) {
+ use Testo;
+
+ my @tests =
+ %{ input => "Raku", output => "Ruka" },
+ %{ input => "Perl", output => "Perl" },
+ %{ input => "Julia", output => "Jaliu" },
+ %{ input => "Uiua", output => "Auiu" },
+ ;
+
+ .<input>.&SOLUTION.&is-eqv: .<output>, .<text> for @tests
+} # end of multi MAIN (Bool :$test!)
+
+