aboutsummaryrefslogtreecommitdiff
path: root/challenge-268
diff options
context:
space:
mode:
authorAndrey Shitov <ash@Andreys-iMac.local>2024-05-08 08:16:06 +0300
committerAndrey Shitov <ash@Andreys-iMac.local>2024-05-08 08:16:06 +0300
commitcaa8f919e75d8a57fd87f44df4f30b20ea629946 (patch)
tree69588dd927420a9b327433a35ff9a9444522e2dc /challenge-268
parent56ecb5995d71ed710da5e103eb89d35e6e450a30 (diff)
downloadperlweeklychallenge-club-caa8f919e75d8a57fd87f44df4f30b20ea629946.tar.gz
perlweeklychallenge-club-caa8f919e75d8a57fd87f44df4f30b20ea629946.tar.bz2
perlweeklychallenge-club-caa8f919e75d8a57fd87f44df4f30b20ea629946.zip
Task 1 Week 268 in Raku by ash
Diffstat (limited to 'challenge-268')
-rw-r--r--challenge-268/ash/raku/ch-1.raku30
1 files changed, 30 insertions, 0 deletions
diff --git a/challenge-268/ash/raku/ch-1.raku b/challenge-268/ash/raku/ch-1.raku
new file mode 100644
index 0000000000..89ab33b4f0
--- /dev/null
+++ b/challenge-268/ash/raku/ch-1.raku
@@ -0,0 +1,30 @@
+# Task 1 of The Weekly Challenge 268
+# https://theweeklychallenge.org/blog/perl-weekly-challenge-268/#TASK1
+
+# Test run:
+# $ raku ch-1.raku
+# 2
+# 3
+# 3
+# No such number
+
+
+my @tests =
+ ([3, 7, 5], [9, 5, 7]),
+ ([1, 2, 1], [5, 4, 4]),
+ ([2], [5]),
+
+ ([3, 7, 5], [9, 5, 17]);
+
+for @tests -> (@a is copy, @b is copy) {
+ @a .= sort;
+ @b .= sort;
+
+ my $diff = @b[0] - @a[0];
+ if (@a >>+>> $diff eqv @b) {
+ say $diff;
+ }
+ else {
+ say "No such number";
+ }
+}