aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Anderson <mark@andemark.io>2025-10-27 11:34:18 +0000
committerMark Anderson <mark@andemark.io>2025-10-27 11:34:18 +0000
commit50ce40a6f64d4590fcc54705502fc48d800d1baa (patch)
tree76a73ca390dbb25b809284d99919a7b8521be827
parent7bb99254c936a0c4b43ecfc95c620b5eb452b305 (diff)
downloadperlweeklychallenge-club-50ce40a6f64d4590fcc54705502fc48d800d1baa.tar.gz
perlweeklychallenge-club-50ce40a6f64d4590fcc54705502fc48d800d1baa.tar.bz2
perlweeklychallenge-club-50ce40a6f64d4590fcc54705502fc48d800d1baa.zip
Challenge 345 Solutions (Raku)
-rw-r--r--challenge-345/mark-anderson/raku/ch-1.raku13
1 files changed, 5 insertions, 8 deletions
diff --git a/challenge-345/mark-anderson/raku/ch-1.raku b/challenge-345/mark-anderson/raku/ch-1.raku
index cd553461a8..513e881298 100644
--- a/challenge-345/mark-anderson/raku/ch-1.raku
+++ b/challenge-345/mark-anderson/raku/ch-1.raku
@@ -12,13 +12,10 @@ is-deeply peak-positions(@arr), peak-positions-alternate(@arr);
sub peak-positions(@ints)
{
- @ints.unshift(0);
- @ints.push(0);
-
- @ints.pairs
- .rotor(3 => -2)
- .grep({ .[0].value < .[1].value > .[2].value })
- .map( { .[0].key })
+ given flat 0, @ints, 0
+ {
+ (^@ints).grep(-> $i { .[$i] < .[$i+1] > .[$i+2] })
+ }
}
sub peak-positions-alternate(@ints)
@@ -38,7 +35,7 @@ sub peak-positions-alternate(@ints)
{
for @m
{
- take .from - 1;
+ take .from;
@histogram[*;.from] = ' ' xx *
}
}