aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-214/mark-anderson/raku/ch-1.raku16
1 files changed, 16 insertions, 0 deletions
diff --git a/challenge-214/mark-anderson/raku/ch-1.raku b/challenge-214/mark-anderson/raku/ch-1.raku
new file mode 100644
index 0000000000..aeb0059f6e
--- /dev/null
+++ b/challenge-214/mark-anderson/raku/ch-1.raku
@@ -0,0 +1,16 @@
+#!/usr/bin/env raku
+use Test;
+
+is-deeply rank-score(<1 2 4 3 5>), <5 4 S B G>>>.Str;
+is-deeply rank-score(<8 5 6 7 4>), <G 4 B S 5>>>.Str;
+is-deeply rank-score(<3 5 4 2>), <B G S 4>>>.Str;
+is-deeply rank-score(<2 5 2 1 7 5 1>), <B S B 4 G S 4>>>.Str;
+is-deeply rank-score(<3 5>), <S G>;
+
+sub rank-score($a)
+{
+ my $u := $a.unique.sort(-*);
+ my $s := <G S B 4 5>...*;
+
+ $a.trans($u => $s.head($u)).comb(/<alnum>/)
+}