aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-079/markus-holzer/raku/ch-2.raku14
1 files changed, 7 insertions, 7 deletions
diff --git a/challenge-079/markus-holzer/raku/ch-2.raku b/challenge-079/markus-holzer/raku/ch-2.raku
index d64fc1a83a..864734a511 100644
--- a/challenge-079/markus-holzer/raku/ch-2.raku
+++ b/challenge-079/markus-holzer/raku/ch-2.raku
@@ -1,10 +1,10 @@
unit sub MAIN( *@N where @N.all ~~ Int );
+sub index-height { @N.pairs.grep( *.value >= $^height ).map: *.key }
+sub index-diff { $^indexes.map({ .[1] - .[0] - 1 if .elems }).sum }
+
say (@N.max...0)
- .map( -> $height {
- @N.pairs.grep( *.value >= $height ).map: *.key })
- .map( -> $indexes {
- $indexes.rotor(2 => -1) })
- .map( -> $index-pairs {
- $index-pairs.map({ .[1] - .[0] - 1 if .elems }).sum })
- .sum; \ No newline at end of file
+ .map( &index-height )
+ .map( *.rotor: 2 => -1 )
+ .map( &index-diff )
+ .sum; \ No newline at end of file