aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-197/mark-anderson/raku/ch-2.raku14
1 files changed, 6 insertions, 8 deletions
diff --git a/challenge-197/mark-anderson/raku/ch-2.raku b/challenge-197/mark-anderson/raku/ch-2.raku
index 01ad3d233f..0aa4b6e32f 100644
--- a/challenge-197/mark-anderson/raku/ch-2.raku
+++ b/challenge-197/mark-anderson/raku/ch-2.raku
@@ -1,17 +1,15 @@
#!/usr/bin/env raku
use Test;
-# My output might be different but I think it's still a wiggle sort.
-
-is-deeply wiggle-sort(1,5,1,1,6,4), (1,4,1,5,1,6);
-is-deeply wiggle-sort(1,3,2,2,3,1), (1,2,1,3,2,3);
+is-deeply wiggle-sort(1,5,1,1,6,4), (1,6,1,5,1,4);
+is-deeply wiggle-sort(1,3,2,2,3,1), (2,3,1,3,1,2);
is-deeply wiggle-sort(1,1,1,2,2,2), (1,2,1,2,1,2);
-is-deeply wiggle-sort(1,2,3,4,5,6,7), (1,5,2,6,3,7,4);
-is-deeply wiggle-sort(1,2,3,4,5,6,7,8), (1,5,2,6,3,7,4,8);
+is-deeply wiggle-sort(1,2,3,4,5,6,7), (4,7,3,6,2,5,1);
+is-deeply wiggle-sort(1,2,3,4,5,6,7,8), (4,8,3,7,2,6,1,5);
sub wiggle-sort(*@a)
{
- @a .= sort;
+ @a .= sort: -*;
my $d = @a / 2;
- flat roundrobin @a.head($d.ceiling), @a.tail($d.floor);
+ flat roundrobin @a.tail($d.ceiling), @a.head($d.floor)
}