diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2023-04-25 11:33:20 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-25 11:33:20 +0100 |
| commit | 8f85486dbac39eedd05e465f9a9fa66c079d45c9 (patch) | |
| tree | a2248c9e404bda0a3af0a659a3763e516d344436 | |
| parent | 9df2d961ae00534346eaaceffaf8cfee4ecc88bb (diff) | |
| parent | 9d16fe75b0ec973971729f62695e3600a7e9502c (diff) | |
| download | perlweeklychallenge-club-8f85486dbac39eedd05e465f9a9fa66c079d45c9.tar.gz perlweeklychallenge-club-8f85486dbac39eedd05e465f9a9fa66c079d45c9.tar.bz2 perlweeklychallenge-club-8f85486dbac39eedd05e465f9a9fa66c079d45c9.zip | |
Merge pull request #7965 from andemark/challenge-214-Raku
Challenge 214 Solutions (Raku)
| -rw-r--r-- | challenge-214/mark-anderson/raku/ch-1.raku | 16 |
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>/) +} |
