aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-083/markus-holzer/raku/ch-1.raku2
-rw-r--r--challenge-083/markus-holzer/raku/ch-2.raku12
2 files changed, 14 insertions, 0 deletions
diff --git a/challenge-083/markus-holzer/raku/ch-1.raku b/challenge-083/markus-holzer/raku/ch-1.raku
new file mode 100644
index 0000000000..6785656edb
--- /dev/null
+++ b/challenge-083/markus-holzer/raku/ch-1.raku
@@ -0,0 +1,2 @@
+unit sub MAIN( Str $S );
+$S.words[ 1 .. *-2 ].join.chars.say \ No newline at end of file
diff --git a/challenge-083/markus-holzer/raku/ch-2.raku b/challenge-083/markus-holzer/raku/ch-2.raku
new file mode 100644
index 0000000000..9bc6e3ee33
--- /dev/null
+++ b/challenge-083/markus-holzer/raku/ch-2.raku
@@ -0,0 +1,12 @@
+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
+