aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <Mohammad.Anwar@yahoo.com>2023-07-13 01:39:09 +0100
committerGitHub <noreply@github.com>2023-07-13 01:39:09 +0100
commitb92e51f543de7bfe97d2ae08ef3731c57c0e01c6 (patch)
tree5c9a0b152dc069003e6ae7db66504a7ca9e90ceb
parent23ccd948f1691977865148b1fd0947180194d6ef (diff)
parent832fcb22fb7e5af716cd931f51722810cd7b07c6 (diff)
downloadperlweeklychallenge-club-b92e51f543de7bfe97d2ae08ef3731c57c0e01c6.tar.gz
perlweeklychallenge-club-b92e51f543de7bfe97d2ae08ef3731c57c0e01c6.tar.bz2
perlweeklychallenge-club-b92e51f543de7bfe97d2ae08ef3731c57c0e01c6.zip
Merge pull request #8366 from jmaslak/master
Solution in Raku for Challenge 225
-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(", ");
+}
+
+