aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <Mohammad.Anwar@yahoo.com>2024-01-07 02:13:05 +0000
committerGitHub <noreply@github.com>2024-01-07 02:13:05 +0000
commit951171990b5e9881a677cb36483ae48249d1c5ff (patch)
treea1d2b29b5a755e66a77ceeacbf183ea890134fd9
parenta067852544a1a06839fdaf1edc3f847ba7e4340b (diff)
parent9091d0a6f53e5537b2ffe01c51ad0b404368838d (diff)
downloadperlweeklychallenge-club-951171990b5e9881a677cb36483ae48249d1c5ff.tar.gz
perlweeklychallenge-club-951171990b5e9881a677cb36483ae48249d1c5ff.tar.bz2
perlweeklychallenge-club-951171990b5e9881a677cb36483ae48249d1c5ff.zip
Merge pull request #9353 from wambash/challenge-week-250
solutions week 250
-rw-r--r--challenge-250/wambash/raku/ch-1.raku20
-rw-r--r--challenge-250/wambash/raku/ch-2.raku20
2 files changed, 40 insertions, 0 deletions
diff --git a/challenge-250/wambash/raku/ch-1.raku b/challenge-250/wambash/raku/ch-1.raku
new file mode 100644
index 0000000000..770cc038fe
--- /dev/null
+++ b/challenge-250/wambash/raku/ch-1.raku
@@ -0,0 +1,20 @@
+#!/usr/bin/env raku
+
+sub smallest-index (+ints) {
+ ints
+ andthen .pairs
+ andthen .first: { .key mod 10 == .value }, :k
+}
+
+multi MAIN (Bool :test($)!) {
+ use Test;
+ is smallest-index(4,3,2,1),2;
+ is smallest-index(0,1,2),0;
+ is smallest-index(1, 2, 3, 4, 5, 6, 7, 8, 9, 0), Nil;
+ is smallest-index(1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 0), 10;
+ done-testing;
+}
+
+multi MAIN (+ints) {
+ say smallest-index( ints ) // -1
+}
diff --git a/challenge-250/wambash/raku/ch-2.raku b/challenge-250/wambash/raku/ch-2.raku
new file mode 100644
index 0000000000..6ef1d88724
--- /dev/null
+++ b/challenge-250/wambash/raku/ch-2.raku
@@ -0,0 +1,20 @@
+#!/usr/bin/env raku
+
+
+
+multi string-value-max ( +alphanumeric-string ) {
+ alphanumeric-string
+ andthen .map: { try { .Int } // .chars }\
+ andthen .max
+}
+
+multi MAIN (Bool :test($)!) {
+ use Test;
+ is string-value-max(<perl 2 000 python r4ku>), 6;
+ is string-value-max(<001 1 000 0001>), 1;
+ done-testing;
+}
+
+multi MAIN (+alpahnumeric-string) {
+ say string-value-max alpahnumeric-string
+}