diff options
| -rw-r--r-- | challenge-345/mark-anderson/raku/ch-1.raku | 13 |
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 * } } |
