aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2023-05-16 11:54:17 +0100
committerGitHub <noreply@github.com>2023-05-16 11:54:17 +0100
commit341d5f43ecb4929a3297d231b0efd2af34e04021 (patch)
tree01299462de10395b115f719ad7092961d2eee185
parent39a9745a30d49b2ac570fec904484ce2f1c5494f (diff)
parent2e39969fccaaa56e1435234574e3c26d648038a8 (diff)
downloadperlweeklychallenge-club-341d5f43ecb4929a3297d231b0efd2af34e04021.tar.gz
perlweeklychallenge-club-341d5f43ecb4929a3297d231b0efd2af34e04021.tar.bz2
perlweeklychallenge-club-341d5f43ecb4929a3297d231b0efd2af34e04021.zip
Merge pull request #8079 from andemark/challenge-217-Raku
Challenge 217 Solutions (Raku)
-rw-r--r--challenge-217/mark-anderson/raku/ch-1.raku11
-rw-r--r--challenge-217/mark-anderson/raku/ch-2.raku15
2 files changed, 26 insertions, 0 deletions
diff --git a/challenge-217/mark-anderson/raku/ch-1.raku b/challenge-217/mark-anderson/raku/ch-1.raku
new file mode 100644
index 0000000000..bad514c662
--- /dev/null
+++ b/challenge-217/mark-anderson/raku/ch-1.raku
@@ -0,0 +1,11 @@
+#!/usr/bin/env raku
+use Test;
+
+is sorted-matrix([3, 1, 2], [5, 2, 4], [0, 1, 3]), 1;
+is sorted-matrix([2, 1], [4, 5]), 4;
+is sorted-matrix([1, 0, 3], [0, 0, 0], [1, 2, 1]), 0;
+
+sub sorted-matrix(+$a)
+{
+ $a.comb(/\d+/).sort(+*)[2];
+}
diff --git a/challenge-217/mark-anderson/raku/ch-2.raku b/challenge-217/mark-anderson/raku/ch-2.raku
new file mode 100644
index 0000000000..5201cea9e5
--- /dev/null
+++ b/challenge-217/mark-anderson/raku/ch-2.raku
@@ -0,0 +1,15 @@
+#!/usr/bin/env raku
+use Test;
+
+# https://www.geeksforgeeks.org/given-an-array-of-numbers-arrange-the-numbers-to-form-the-biggest-number/
+
+is max-num(1, 23), 231;
+is max-num(10, 3, 2), 3210;
+is max-num(31, 2, 4, 10), 431210;
+is max-num(5, 11, 4, 1, 2), 542111;
+is max-num(1, 10), 110;
+
+sub max-num(+$a)
+{
+ $a.sort({ $^b ~ $^a cmp $^a ~ $^b }).join
+}