aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <Mohammad.Anwar@yahoo.com>2025-08-03 23:17:45 +0100
committerGitHub <noreply@github.com>2025-08-03 23:17:45 +0100
commit8d9f4ffb9f8038197c859454dd8fe6fdb94e808e (patch)
tree781aeb8ec5db85c7f420e6d513e0b4848cd6d982
parent3704f450d9c484de332af4ecccc05fb126409478 (diff)
parent7e36db5b0da6092d9bcb101b9487633773b6ab1a (diff)
downloadperlweeklychallenge-club-8d9f4ffb9f8038197c859454dd8fe6fdb94e808e.tar.gz
perlweeklychallenge-club-8d9f4ffb9f8038197c859454dd8fe6fdb94e808e.tar.bz2
perlweeklychallenge-club-8d9f4ffb9f8038197c859454dd8fe6fdb94e808e.zip
Merge pull request #12457 from BarrOff/barroff-332
feat: add solutions for challenge 332 from BarrOff
-rw-r--r--challenge-332/barroff/raku/ch-1.p633
-rw-r--r--challenge-332/barroff/raku/ch-2.p622
2 files changed, 55 insertions, 0 deletions
diff --git a/challenge-332/barroff/raku/ch-1.p6 b/challenge-332/barroff/raku/ch-1.p6
new file mode 100644
index 0000000000..7f0bb5fbc8
--- /dev/null
+++ b/challenge-332/barroff/raku/ch-1.p6
@@ -0,0 +1,33 @@
+#!/usr/bin/env raku
+
+use v6.d;
+
+my $bin-format = sub ($self) {
+ sprintf "%d-%d-%d",
+ .year.base(2),
+ .month.base(2),
+ .day.base(2)
+ given $self;
+}
+
+sub binary-date(Str $date --> Str) {
+ Str(Date.new($date, formatter => $bin-format))
+}
+
+#| Run test cases
+multi sub MAIN('test') {
+ use Test;
+ plan 3;
+
+ is binary-date("2025-07-26"), "11111101001-111-11010",
+ 'works for "2025-07-26"';
+ is binary-date("2000-02-02"), "11111010000-10-10",
+ 'works for "2000-02-02"';
+ is binary-date("2024-12-31"), "11111101000-1100-11111",
+ 'works for "2024-12-31"';
+}
+
+#| Take user provided date like "2025-07-26"
+multi sub MAIN(Str $date) {
+ say binary-date($date);
+}
diff --git a/challenge-332/barroff/raku/ch-2.p6 b/challenge-332/barroff/raku/ch-2.p6
new file mode 100644
index 0000000000..b3757c52b1
--- /dev/null
+++ b/challenge-332/barroff/raku/ch-2.p6
@@ -0,0 +1,22 @@
+#!/usr/bin/env raku
+
+use v6.d;
+
+sub odd-leters(Str $str --> Bool) {
+ so map({ $_ mod 2 }, $str.comb.Bag.values).all == 1;
+}
+
+#| Run test cases
+multi sub MAIN('test') {
+ use Test;
+ plan 3;
+
+ is odd-leters("weekly"), False, 'works for "weekly"';
+ is odd-leters("perl"), True, 'works for "perl"';
+ is odd-leters("challenge"), False, 'works for "challenge"';
+}
+
+#| Take user provided string like "perl"
+multi sub MAIN(Str $str) {
+ say odd-leters($str);
+}