diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2020-07-27 23:59:05 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-27 23:59:05 +0100 |
| commit | cd0c014671578c69b7dc7b30b91cccb4b8702fe2 (patch) | |
| tree | 214e7d3083452e4b8fbfd05cd8178ad26dac499b | |
| parent | 0531f082003a6c1f44492785ec944ee9fc428d33 (diff) | |
| parent | 82d07e235c3514db06ed58f44eb9f7180546a0ed (diff) | |
| download | perlweeklychallenge-club-cd0c014671578c69b7dc7b30b91cccb4b8702fe2.tar.gz perlweeklychallenge-club-cd0c014671578c69b7dc7b30b91cccb4b8702fe2.tar.bz2 perlweeklychallenge-club-cd0c014671578c69b7dc7b30b91cccb4b8702fe2.zip | |
Merge pull request #1990 from andemark/branch-for-challenge-071
Peaks Solution
| -rw-r--r-- | challenge-071/mark-anderson/raku/ch-1.raku | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/challenge-071/mark-anderson/raku/ch-1.raku b/challenge-071/mark-anderson/raku/ch-1.raku new file mode 100644 index 0000000000..e255aecde1 --- /dev/null +++ b/challenge-071/mark-anderson/raku/ch-1.raku @@ -0,0 +1,19 @@ +#!/usr/bin/env raku + +unit sub MAIN(UInt $N where 1 < $N <= 50); + +my @array = (1..50).pick($N); + +my $regex = / [^|\s] (\d+) \s (\d+) \s (\d+) [\s|$] <?{ $0 < $1 > $2 }> /; + +my @peaks = gather { + take @array[0] if @array[0] > @array[1]; + + take ~.[1] for @array.join(" ").match($regex, :overlap); + + take @array[*-1] if @array[*-1] > @array[*-2]; +} + +say "Array: ", @array, "\n"; + +say "Peaks: ", @peaks; |
