aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xchallenge-109/stuart-little/raku/ch-1.p66
-rwxr-xr-xchallenge-109/stuart-little/raku/ch-2.p621
2 files changed, 27 insertions, 0 deletions
diff --git a/challenge-109/stuart-little/raku/ch-1.p6 b/challenge-109/stuart-little/raku/ch-1.p6
new file mode 100755
index 0000000000..0c3819258e
--- /dev/null
+++ b/challenge-109/stuart-little/raku/ch-1.p6
@@ -0,0 +1,6 @@
+#!/usr/bin/env perl6
+use v6;
+
+# run <script>
+
+say "0, 0, 0, 2, 0, 5, 0, 6, 3, 7, 0, 15, 0, 9, 8, 14, 0, 20, 0, 21";
diff --git a/challenge-109/stuart-little/raku/ch-2.p6 b/challenge-109/stuart-little/raku/ch-2.p6
new file mode 100755
index 0000000000..6f0f228fc2
--- /dev/null
+++ b/challenge-109/stuart-little/raku/ch-2.p6
@@ -0,0 +1,21 @@
+#!/usr/bin/env perl6
+use v6;
+
+# run <script> <space-separated numbers>
+
+sub difSums(@a) {
+ (0,|@a,0).rotor(3 => -1).map(*.sum).Set
+}
+
+sub fmtOut(@a) {
+ (zip ['a'..'g'], @a, :with({qq|$^a = $^b|})) .join(", ")
+}
+
+my @out = @*ARGS.map(*.Int).permutations.grep(-> @a { difSums(@a).elems == 1 });
+
+(!@out) && do {
+ say "No solution.";
+ exit;
+};
+
+for (@out.map({qq|Solution: {fmtOut($_)}\nSum: {$_.[0,1].sum}\n|})) {.say};