diff options
| author | Mohammad Sajid Anwar <Mohammad.Anwar@yahoo.com> | 2025-05-20 09:08:18 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-20 09:08:18 +0100 |
| commit | e19dbdb31c4d8714a42398ca58757b665864225c (patch) | |
| tree | 51b4fcb94de53b05fc513f34277df11ff4f77d33 | |
| parent | 6c467a026c325f27386294744ad5d0456d6c1c50 (diff) | |
| parent | 880fa7e6b98f0cdf298655b839026b0de6d0a317 (diff) | |
| download | perlweeklychallenge-club-e19dbdb31c4d8714a42398ca58757b665864225c.tar.gz perlweeklychallenge-club-e19dbdb31c4d8714a42398ca58757b665864225c.tar.bz2 perlweeklychallenge-club-e19dbdb31c4d8714a42398ca58757b665864225c.zip | |
Merge pull request #12044 from ash/ash-322
Solutions Week 322 in Raku by @ash
| -rw-r--r-- | challenge-322/ash/raku/ch-1.raku | 14 | ||||
| -rw-r--r-- | challenge-322/ash/raku/ch-2.raku | 12 |
2 files changed, 26 insertions, 0 deletions
diff --git a/challenge-322/ash/raku/ch-1.raku b/challenge-322/ash/raku/ch-1.raku new file mode 100644 index 0000000000..a54b060bfe --- /dev/null +++ b/challenge-322/ash/raku/ch-1.raku @@ -0,0 +1,14 @@ +# Task 1 of the Weekly Challenge 322 +# https://theweeklychallenge.org/blog/perl-weekly-challenge-322/#TASK1 + +say split-groups('ABC-D-E-F', 3); # ABC-DEF +say split-groups('A-BC-D-E', 2); # A-BC-DE +say split-groups('-A-B-CD-E', 4); # A-BCDE + +sub split-groups($str is copy, $i) { + $str ~~ s:g/\W//; + + $str ~~ s/ (\w) (\w**{$i} ('-' | $)) /$0-$1/ while $str ~~ /^\w**{$i + 1}/; + + return $str; +} diff --git a/challenge-322/ash/raku/ch-2.raku b/challenge-322/ash/raku/ch-2.raku new file mode 100644 index 0000000000..5d15aee2f6 --- /dev/null +++ b/challenge-322/ash/raku/ch-2.raku @@ -0,0 +1,12 @@ +# Task 2 of the Weekly Challenge 322 +# https://theweeklychallenge.org/blog/perl-weekly-challenge-322/#TASK2 + +say rank 55, 22, 44, 33; # (4 1 3 2) +say rank 10, 10, 10; # (1 1 1) +say rank 5, 1, 1, 4, 3; # (4, 1, 1, 3, 2) + +sub rank(*@ints) { + my %rank = @ints.sort.unique.kv.reverse; + + return @ints.map({%rank{$_} + 1}); +} |
