aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-086/wambash/raku/ch-1.raku20
1 files changed, 20 insertions, 0 deletions
diff --git a/challenge-086/wambash/raku/ch-1.raku b/challenge-086/wambash/raku/ch-1.raku
new file mode 100644
index 0000000000..5e20c27832
--- /dev/null
+++ b/challenge-086/wambash/raku/ch-1.raku
@@ -0,0 +1,20 @@
+#!/usr/bin/env raku
+
+
+sub pair-difference ( $a, +@n ) {
+ @n
+ andthen .combinations(2)
+ andthen .first: { abs( .[0] - .[1] ) == abs $a }
+}
+
+multi MAIN (Bool :$test) {
+ use Test;
+ is pair-difference( 7, (10, 8, 12, 15, 5)), (8, 15);
+ is pair-difference(-7, (10, 8, 12, 15, 5)), (8, 15);
+ is pair-difference( 6, (1, 5, 2, 9, 7)), (1, 7);
+ is pair-difference(15, (10, 30, 20, 50, 40)), Nil;
+}
+
+multi MAIN ($a, +@n) {
+ say +so pair-difference $a, @n
+}