diff options
| -rw-r--r-- | challenge-083/markus-holzer/raku/ch-2.raku | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/challenge-083/markus-holzer/raku/ch-2.raku b/challenge-083/markus-holzer/raku/ch-2.raku index 9bc6e3ee33..cac6e2cf7c 100644 --- a/challenge-083/markus-holzer/raku/ch-2.raku +++ b/challenge-083/markus-holzer/raku/ch-2.raku @@ -1,12 +1,11 @@ unit sub MAIN( *@A ); -my &neg = *.grep: * < 0; - -say + neg # find and count all negative numbers of - ( [X] map { +$_, -$_ }, @A ) # all possible candidates - .classify( *.sum ) # grouped by sum - .grep( *.key > -1 ) # filtered where sum is positive - .sort( *.key ) # sorted by sum - .head.value # closest to zero - .min( &neg ) # the one with the least flips +my &less-than-zero = *.grep: * < 0; +say +less-than-zero # find and count all negative numbers of + ( [X] map { +$_, -$_ }, @A ) # all possible candidates + .classify( *.sum ) # grouped by sum + .grep( *.key > -1 ) # filtered where sum is positive + .sort( *.key ) # sorted by sum + .head.value # closest to zero + .min( &less-than-zero ) # the one with the least flips
\ No newline at end of file |
