aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xchallenge-225/joelle-maslak/raku/ch-1.raku14
-rwxr-xr-xchallenge-225/joelle-maslak/raku/ch-2.raku25
2 files changed, 39 insertions, 0 deletions
diff --git a/challenge-225/joelle-maslak/raku/ch-1.raku b/challenge-225/joelle-maslak/raku/ch-1.raku
new file mode 100755
index 0000000000..547d9fd6ba
--- /dev/null
+++ b/challenge-225/joelle-maslak/raku/ch-1.raku
@@ -0,0 +1,14 @@
+#!/usr/bin/env raku
+use v6.d;
+
+my Str:D @INPUT = ("Perl and Raku belong to the same family.",
+ "I love Perl.",
+ "The Perl and Raku Conference.");
+
+sub MAIN(*@input) {
+ @input = @INPUT unless @input.elems;
+
+ say "Max words: " ~ max @input».words».elems.max;
+}
+
+
diff --git a/challenge-225/joelle-maslak/raku/ch-2.raku b/challenge-225/joelle-maslak/raku/ch-2.raku
new file mode 100755
index 0000000000..3c5f6fd4aa
--- /dev/null
+++ b/challenge-225/joelle-maslak/raku/ch-2.raku
@@ -0,0 +1,25 @@
+#!/usr/bin/env raku
+use v6.d;
+
+my @INPUT = (10, 4, 8, 3);
+
+sub leftsum(@numbers) {
+ return () unless @numbers.elems;
+ gather {
+ for 0..^(@numbers.elems) -> $i {
+ take @numbers[0..^$i].sum;
+ }
+ }
+}
+
+sub MAIN(*@input) {
+ @input = @INPUT unless @input.elems;
+
+ my @left = leftsum(@input);
+ my @right = leftsum(@input.reverse).reverse;
+
+ my @differences = (@left Z @right).map: {abs($^a[0] - $^a[1])};
+ say "Left/right sum differences: " ~ @differences.join(", ");
+}
+
+