From d623814570e3f9ad2e00e96eabbfbd6a3aa51fb9 Mon Sep 17 00:00:00 2001 From: Jan Krňávek Date: Sun, 15 Nov 2020 09:11:17 +0100 Subject: solution week 086-1 — works with negative $a MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- challenge-086/wambash/raku/ch-1.raku | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/challenge-086/wambash/raku/ch-1.raku b/challenge-086/wambash/raku/ch-1.raku index fe798ce7b1..5e20c27832 100644 --- a/challenge-086/wambash/raku/ch-1.raku +++ b/challenge-086/wambash/raku/ch-1.raku @@ -4,12 +4,13 @@ sub pair-difference ( $a, +@n ) { @n andthen .combinations(2) - andthen .first: {abs( .[0] - .[1] ) == $a} + 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; } -- cgit