diff options
| author | Mohammad Sajid Anwar <Mohammad.Anwar@yahoo.com> | 2025-05-13 13:20:36 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-13 13:20:36 +0100 |
| commit | 9f9212572f40fc04654ca829356baedbf9acecb1 (patch) | |
| tree | 1ada9bb679b7409b34ccf74075121d02487ed442 | |
| parent | 0e6b0e59098d55cb7c2b944f16e9414a886092db (diff) | |
| parent | 5dcdabe68205622b90a368cb3403dbc67174ca13 (diff) | |
| download | perlweeklychallenge-club-9f9212572f40fc04654ca829356baedbf9acecb1.tar.gz perlweeklychallenge-club-9f9212572f40fc04654ca829356baedbf9acecb1.tar.bz2 perlweeklychallenge-club-9f9212572f40fc04654ca829356baedbf9acecb1.zip | |
Merge pull request #12016 from ash/ash-321
Ash 321
| -rw-r--r-- | challenge-321/ash/raku/ch-1.raku | 20 | ||||
| -rw-r--r-- | challenge-321/ash/raku/ch-2.raku | 19 |
2 files changed, 39 insertions, 0 deletions
diff --git a/challenge-321/ash/raku/ch-1.raku b/challenge-321/ash/raku/ch-1.raku new file mode 100644 index 0000000000..7e7cbb3642 --- /dev/null +++ b/challenge-321/ash/raku/ch-1.raku @@ -0,0 +1,20 @@ +# Task 1 of the Weekly Challenge 321 +# https://theweeklychallenge.org/blog/perl-weekly-challenge-321/#TASK1 + +my @nums = 1, 2, 4, 3, 5, 6; # 1 +# my @nums = 0, 2, 4, 8, 3, 5; # 2 +# my @nums = 7, 3, 1, 0, 5, 9; # 2 + +my @avg = gather { + while (@nums) { + my $min = @nums.min; + my $max = @nums.max; + + my $avg = ($min + $max) / 2; + take $avg; + + @nums.=grep: * ∉ (@nums.min, @nums.max); + } +} + +say @avg.unique.elems; diff --git a/challenge-321/ash/raku/ch-2.raku b/challenge-321/ash/raku/ch-2.raku new file mode 100644 index 0000000000..904586b279 --- /dev/null +++ b/challenge-321/ash/raku/ch-2.raku @@ -0,0 +1,19 @@ +# Task 2 of the Weekly Challenge 321 +# https://theweeklychallenge.org/blog/perl-weekly-challenge-321/#TASK2 + +my $str1 = 'ab#c'; +my $str2 = 'ad#c'; # True + +# my $str1 = 'ab##'; +# my $str2 = 'a#b#'; # True + +# my $str1 = 'a#b'; +# my $str2 = 'c'; # False + +say process($str1) eq process($str2); + +sub process($s is copy) { + $s ~~ s/.\#// while $s ~~ /.\#/; + + return $s; +} |
