diff options
| author | Andrew Shitov <mail@andreyshitov.com> | 2025-10-27 09:32:53 +0100 |
|---|---|---|
| committer | Andrew Shitov <mail@andreyshitov.com> | 2025-10-27 09:32:53 +0100 |
| commit | 01be821ef5ccd02011cad0d9927b873300bd6800 (patch) | |
| tree | d57134cddeb10992002ba95b03a56d08ed464b3a | |
| parent | 9b1eba54d5e59d05df44f336120a6a03be62a645 (diff) | |
| download | perlweeklychallenge-club-01be821ef5ccd02011cad0d9927b873300bd6800.tar.gz perlweeklychallenge-club-01be821ef5ccd02011cad0d9927b873300bd6800.tar.bz2 perlweeklychallenge-club-01be821ef5ccd02011cad0d9927b873300bd6800.zip | |
Task 1 Week 345 in Raku by @ash
| -rw-r--r-- | challenge-345/ash/raku/ch-1.raku | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/challenge-345/ash/raku/ch-1.raku b/challenge-345/ash/raku/ch-1.raku new file mode 100644 index 0000000000..bc53c65653 --- /dev/null +++ b/challenge-345/ash/raku/ch-1.raku @@ -0,0 +1,13 @@ +# Task 1 of the Weekly Challenge 345 +# https://theweeklychallenge.org/blog/perl-weekly-challenge-345/#TASK1 + +say peaks 1, 3, 2; # 1 +say peaks 2, 4, 6, 5, 3; # 2 +say peaks 1, 2, 3, 2, 4, 1; # 2 4 +say peaks 5, 3, 1; # 0 +say peaks 1, 5, 1, 5, 1, 5, 1; # 1 3 5 + +sub peaks(*@data) { + my @indices = 1 .. (@data.elems - 2); + return (@indices.grep: {@data[$_ - 1] < @data[$_] > @data[$_ + 1]}) || (0,); +} |
