From 50ce40a6f64d4590fcc54705502fc48d800d1baa Mon Sep 17 00:00:00 2001 From: Mark Anderson Date: Mon, 27 Oct 2025 11:34:18 +0000 Subject: Challenge 345 Solutions (Raku) --- challenge-345/mark-anderson/raku/ch-1.raku | 13 +++++-------- 1 file 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 * } } -- cgit