diff options
| author | Jan Krňávek <Jan.Krnavek@gmail.com> | 2025-07-13 13:25:28 +0200 |
|---|---|---|
| committer | Jan Krňávek <Jan.Krnavek@gmail.com> | 2025-07-13 13:25:28 +0200 |
| commit | e2eb93aca73fa4fdf0ae970e1049ee7285b4e324 (patch) | |
| tree | 822202012a3bc80c84d86abda641dcd5cc8bd56b | |
| parent | 67f8df57472ca970259dcaa18a6b61f400df7ff2 (diff) | |
| download | perlweeklychallenge-club-e2eb93aca73fa4fdf0ae970e1049ee7285b4e324.tar.gz perlweeklychallenge-club-e2eb93aca73fa4fdf0ae970e1049ee7285b4e324.tar.bz2 perlweeklychallenge-club-e2eb93aca73fa4fdf0ae970e1049ee7285b4e324.zip | |
solutions week 329
| -rw-r--r-- | challenge-329/wambash/raku/ch-1.raku | 19 | ||||
| -rw-r--r-- | challenge-329/wambash/raku/ch-2.raku | 29 |
2 files changed, 48 insertions, 0 deletions
diff --git a/challenge-329/wambash/raku/ch-1.raku b/challenge-329/wambash/raku/ch-1.raku new file mode 100644 index 0000000000..39f015b725 --- /dev/null +++ b/challenge-329/wambash/raku/ch-1.raku @@ -0,0 +1,19 @@ +#!/usr/bin/env raku + +sub counter-integers ($str) { + $str + andthen .comb: /\d+/ + andthen .unique +} + +multi MAIN (Bool :test($)!) { + use Test; + is counter-integers('the1weekly2challenge2'), (1,2); + is counter-integers('go21od1lu5c7k'), (21, 1, 5,7); + is counter-integers('4p3e2r1l'), (4,3,2,1); + done-testing; +} + +multi MAIN ($str) { + put counter-integers $str; +} diff --git a/challenge-329/wambash/raku/ch-2.raku b/challenge-329/wambash/raku/ch-2.raku new file mode 100644 index 0000000000..a910e9bca3 --- /dev/null +++ b/challenge-329/wambash/raku/ch-2.raku @@ -0,0 +1,29 @@ +#!/usr/bin/env raku + +sub nice-string ($str) { + my @nice = ( + $str + andthen .comb(/<:Lu>/)».lc ∩ .comb(/<:Ll>/) + andthen .keys + ); + #note @nice; + $str + andthen .comb: rx:i/<@nice>+/ + andthen .elems <= 1 ?? |$_ // '' !! .map: &nice-string + andthen .max: *.chars +} + +multi MAIN (Bool :test($)!) { + use Test; + is nice-string('YaaAho'), 'aaA'; + is nice-string('cC'), 'cC'; + is nice-string('A'), ''; + is nice-string('Cc'), 'Cc'; + is nice-string('YaaAhaAo'), 'aaA'; + is nice-string('YaaAhaAHo'), 'aaAhaAH'; + done-testing; +} + +multi MAIN (+$str) { + say nice-string $str; +} |
