aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Shitov <mail@andreyshitov.com>2024-03-18 08:01:07 +0100
committerAndrew Shitov <mail@andreyshitov.com>2024-03-18 08:01:07 +0100
commit203cde4aa1b9923988b6576eff6efd4adc5f3a70 (patch)
treeecc76b4c3f25a9618b4a0581a56124641f1c94b3
parentcad939ed2335566e31b26c5b74b9fc99c23db7a5 (diff)
downloadperlweeklychallenge-club-203cde4aa1b9923988b6576eff6efd4adc5f3a70.tar.gz
perlweeklychallenge-club-203cde4aa1b9923988b6576eff6efd4adc5f3a70.tar.bz2
perlweeklychallenge-club-203cde4aa1b9923988b6576eff6efd4adc5f3a70.zip
Raku solutions by ash
-rw-r--r--challenge-261/ash/raku/ch-1.raku19
-rw-r--r--challenge-261/ash/raku/ch-2.raku20
2 files changed, 39 insertions, 0 deletions
diff --git a/challenge-261/ash/raku/ch-1.raku b/challenge-261/ash/raku/ch-1.raku
new file mode 100644
index 0000000000..1c6a73c9ac
--- /dev/null
+++ b/challenge-261/ash/raku/ch-1.raku
@@ -0,0 +1,19 @@
+# Solution to the Task 1 of The Weekly Challenge 261
+# https://theweeklychallenge.org/blog/perl-weekly-challenge-261/#TASK1
+
+# Test run:
+# $ raku ch-1.raku
+# 36
+# 9
+# 0
+
+my @tests =
+ (1, 2, 3, 45),
+ (1, 12, 3),
+ (1, 2, 3, 4);
+
+for @tests -> @test {
+ my $sum = [+] @test;
+ my $dig = [+]((@test.map: *.comb).flat);
+ say ($dig - $sum).abs;
+}
diff --git a/challenge-261/ash/raku/ch-2.raku b/challenge-261/ash/raku/ch-2.raku
new file mode 100644
index 0000000000..6864850b42
--- /dev/null
+++ b/challenge-261/ash/raku/ch-2.raku
@@ -0,0 +1,20 @@
+# Solution to the Task 2 of The Weekly Challenge 261
+# https://theweeklychallenge.org/blog/perl-weekly-challenge-261/#TASK2
+
+# Test run:
+# $ raku ch-2.raku
+# 24
+# 8
+# 2
+
+my @tests =
+ ((5,3,6,1,12), 3),
+ ((1,2,4,3), 1),
+ ((5,6,7), 2);
+
+for @tests -> (@ints, $start is copy) {
+ my $ints = @ints.Bag;
+
+ $start *= 2 while $ints{$start};
+ say $start;
+}