diff options
| author | Jan Krňávek <Jan.Krnavek@gmail.com> | 2022-11-13 22:57:51 +0100 |
|---|---|---|
| committer | Jan Krňávek <Jan.Krnavek@gmail.com> | 2022-11-13 22:57:51 +0100 |
| commit | 2d5c90ff101d935bafe7f2ca19a637335e652c4a (patch) | |
| tree | 2ff5ba5ef433be773766a7d5c041611d5a2c1cf1 | |
| parent | a3a5e396592490fe027c858ba2029afc1b98f0ce (diff) | |
| download | perlweeklychallenge-club-2d5c90ff101d935bafe7f2ca19a637335e652c4a.tar.gz perlweeklychallenge-club-2d5c90ff101d935bafe7f2ca19a637335e652c4a.tar.bz2 perlweeklychallenge-club-2d5c90ff101d935bafe7f2ca19a637335e652c4a.zip | |
solutions week 190
| -rw-r--r-- | challenge-190/wambash/raku/ch-1.raku | 19 | ||||
| -rw-r--r-- | challenge-190/wambash/raku/ch-2.raku | 34 |
2 files changed, 53 insertions, 0 deletions
diff --git a/challenge-190/wambash/raku/ch-1.raku b/challenge-190/wambash/raku/ch-1.raku new file mode 100644 index 0000000000..adffa1d7db --- /dev/null +++ b/challenge-190/wambash/raku/ch-1.raku @@ -0,0 +1,19 @@ +#!/usr/bin/env raku + +sub capital-detection ($s) { + $s + andthen .contains: / ^ [ <:LC> <:Ll>+ | <:Lu>+ ] $ / +} + +multi MAIN (Bool :test($)!) { + use Test; + is capital-detection('Perl'), True; + is capital-detection('TPRF'), True; + is capital-detection('PyThon'),False; + is capital-detection('raku'), True; + done-testing; +} + +multi MAIN ($s) { + say +capital-detection $s +} diff --git a/challenge-190/wambash/raku/ch-2.raku b/challenge-190/wambash/raku/ch-2.raku new file mode 100644 index 0000000000..55d4ea667b --- /dev/null +++ b/challenge-190/wambash/raku/ch-2.raku @@ -0,0 +1,34 @@ +#!/usr/bin/env raku + +multi decode(Int(Str) $coded-char) { + chr $coded-char + 'A'.ord - 1 +} + +multi decode(+@coded-str) { + @coded-str + andthen .map: &decode + andthen .join +} + +sub decoded-list (Int(Str) $s) { + $s + andthen m:ex{ ^(\d|\d**2 <?{$/ <= 26}>)+$ } #> + andthen .map: *.[0]>>.Int + andthen .map: &decode + andthen .reverse +} + +multi MAIN (Bool :test($)!) { + use Test; + is decode(1),'A'; + is decode(26),'Z'; + is decode(1,7,15,26), 'AGOZ'; + is decoded-list(11), ('AA','K'); + is decoded-list(1115), <AAAE AAO AKE KAE KO>; + is decoded-list(127), ('ABG','LG'); + done-testing; +} + +multi MAIN (Int $s) { + put decoded-list $s +} |
