aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <Mohammad.Anwar@yahoo.com>2025-08-03 23:14:17 +0100
committerGitHub <noreply@github.com>2025-08-03 23:14:17 +0100
commit9ea250a98e1d7ac0c1b2e05608bcbd59776e43b1 (patch)
treec00c1d009c2e4ccf2ad719ce36b94036389c9fb7
parent8d9614e549a551242b4f01ab81db31572f284534 (diff)
parent932b42303fb5cd04b80c13e4da44676684c48b8c (diff)
downloadperlweeklychallenge-club-9ea250a98e1d7ac0c1b2e05608bcbd59776e43b1.tar.gz
perlweeklychallenge-club-9ea250a98e1d7ac0c1b2e05608bcbd59776e43b1.tar.bz2
perlweeklychallenge-club-9ea250a98e1d7ac0c1b2e05608bcbd59776e43b1.zip
Merge pull request #12453 from 0rir/work
332
-rw-r--r--challenge-332/0rir/raku/ch-1.raku46
-rw-r--r--challenge-332/0rir/raku/ch-2.raku57
2 files changed, 103 insertions, 0 deletions
diff --git a/challenge-332/0rir/raku/ch-1.raku b/challenge-332/0rir/raku/ch-1.raku
new file mode 100644
index 0000000000..635b478317
--- /dev/null
+++ b/challenge-332/0rir/raku/ch-1.raku
@@ -0,0 +1,46 @@
+#!/usr/bin/env raku
+# :vim ft=raku sw=4 expandtab # 🦋 ∅∪∩∋∈∉⊆ ≡ ≢ «␤ » ∴ 🐧
+use v6.d;
+use Test;
+
+=begin comment
+332-Task 1: Binary Date Submitted by: Mohammad Sajid Anwar
+You are given a date in the format YYYY-MM-DD.
+
+Write a script to convert it into binary date.
+
+
+Example 1
+Input: $date = "2025-07-26"
+Output: "11111101001-111-11010"
+
+Example 2
+Input: $date = "2000-02-02"
+Output: "11111010000-10-10"
+
+Example 3
+Input: $date = "2024-12-31"
+Output: "11111101000-1100-11111"
+=end comment
+
+my @Test =
+ "2025-07-26", "11111101001-111-11010",
+ "2000-02-02", "11111010000-10-10",
+ "2024-12-31", "11111101000-1100-11111",
+;
+plan +@Test ÷ 2;
+
+sub task( $a) {
+ join '-', $a.split( '-').map: *.Int.base(2);
+}
+
+for @Test -> $in, $exp {
+ is task( $in), $exp, "{$exp // $exp.^name()} <- $in.raku()";
+}
+done-testing;
+
+my $date = "2525-01-01";
+say "
+Input: \$date = \"$date\"
+Output: \"", &task( $date), '"';
+
diff --git a/challenge-332/0rir/raku/ch-2.raku b/challenge-332/0rir/raku/ch-2.raku
new file mode 100644
index 0000000000..d2d7a2f02f
--- /dev/null
+++ b/challenge-332/0rir/raku/ch-2.raku
@@ -0,0 +1,57 @@
+#!/usr/bin/env raku
+# :vim ft=raku sw=4 expandtab # 🦋 ∅∪∩∋∈∉⊆ ≡ ≢ «␤ » ∴ 🐧
+use v6.d;
+use Test;
+
+=begin comment
+332-Task 2: Odd Letters Submitted by: Mohammad Sajid Anwar
+You are given a string.
+
+Write a script to find out if each letter in the given string appeared odd number of times.
+
+
+Example 1
+Input: $str = "weekly"
+Output: false
+
+w: 1 time
+e: 2 times
+k: 1 time
+l: 1 time
+y: 1 time
+
+The letter 'e' appeared 2 times i.e. even.
+
+Example 2
+Input: $str = "perl"
+Output: true
+
+Example 3
+Input: $source = "challenge"
+Output: false
+=end comment
+
+my @Test =
+ "weekly", False,
+ "perl", True,
+ "challenge", False,
+ "abcdefghijk", True,
+ 'a-b_c+d×e%f&123()gh=ijk', True,
+ 'a-a_c+d×e%f&123()gh=ijk', False,
+;
+plan +@Test ÷ 2;
+
+sub task( Str $a -->Bool) {
+ !defined
+ $a.comb.grep( /<:L>/ )
+ .Bag.first( :k, *.value %% 2[0])
+}
+
+for @Test -> $in, $exp {
+ is task( $in), $exp, "{$exp // $exp.^name()} <- $in.raku()";
+}
+done-testing;
+
+my $source = "mn * o - p + qr - s^^3 ~ aaa # wxyz";
+say qq{\nInput: \$source = "$source"\n}
+ ~ qq{Output: &task($source)};