diff options
| author | Mark Anderson <mark@frontrangerunner.com> | 2020-10-05 00:05:16 -0600 |
|---|---|---|
| committer | Mark Anderson <mark@frontrangerunner.com> | 2020-10-05 00:05:16 -0600 |
| commit | f75cdace1c2753c906e90ee441d6ca245ba1e753 (patch) | |
| tree | 34fb9b8bb83b237cdbe3a6b050efc5843249ba17 | |
| parent | cef248ba491398a30061ba49fbc2a824116ae996 (diff) | |
| download | perlweeklychallenge-club-f75cdace1c2753c906e90ee441d6ca245ba1e753.tar.gz perlweeklychallenge-club-f75cdace1c2753c906e90ee441d6ca245ba1e753.tar.bz2 perlweeklychallenge-club-f75cdace1c2753c906e90ee441d6ca245ba1e753.zip | |
Challenge 81 Solutions (Raku)
| -rw-r--r-- | challenge-081/mark-anderson/raku/ch-1.raku | 14 | ||||
| -rw-r--r-- | challenge-081/mark-anderson/raku/ch-2.raku | 12 | ||||
| -rw-r--r-- | challenge-081/mark-anderson/raku/file.txt | 15 |
3 files changed, 41 insertions, 0 deletions
diff --git a/challenge-081/mark-anderson/raku/ch-1.raku b/challenge-081/mark-anderson/raku/ch-1.raku new file mode 100644 index 0000000000..5bcb7776ed --- /dev/null +++ b/challenge-081/mark-anderson/raku/ch-1.raku @@ -0,0 +1,14 @@ +say common-base-strings("abcdabcd", "abcdabcdabcdabcd"); +say common-base-strings("aaa", "aa"); + +sub common-base-strings($str1, $str2) { + + sub base-strings($str) { + gather { + take $str; + take ~$_[0] for $str ~~ m:ex/(\w+)$0/; + } + } + + sort keys base-strings($str1) (&) base-strings($str2); +} diff --git a/challenge-081/mark-anderson/raku/ch-2.raku b/challenge-081/mark-anderson/raku/ch-2.raku new file mode 100644 index 0000000000..21e79f2491 --- /dev/null +++ b/challenge-081/mark-anderson/raku/ch-2.raku @@ -0,0 +1,12 @@ +unit sub MAIN($file); + +say freq-sort($file).join("\n\n"); + +sub freq-sort($file) { + my %h; + + %h{$_}++ for $file.IO.slurp andthen S:g/<[."(),]>|\'s|\-\-/ /.words; + + gather take "{.key} {|.value.sort}" + for %h.classify({.value}, :as{.key}).sort; +} diff --git a/challenge-081/mark-anderson/raku/file.txt b/challenge-081/mark-anderson/raku/file.txt new file mode 100644 index 0000000000..f7786e4f1b --- /dev/null +++ b/challenge-081/mark-anderson/raku/file.txt @@ -0,0 +1,15 @@ +West Side Story + +The award-winning adaptation of the classic romantic tragedy "Romeo +and Juliet". The feuding families become two warring New York City +gangs, the white Jets led by Riff and the Latino Sharks, led by +Bernardo. Their hatred escalates to a point where neither can coexist +with any form of understanding. But when Riff's best friend (and +former Jet) Tony and Bernardo's younger sister Maria meet at a +dance, no one can do anything to stop their love. Maria and Tony +begin meeting in secret, planning to run away. Then the Sharks and +Jets plan a rumble under the highway--whoever wins gains control +of the streets. Maria sends Tony to stop it, hoping it can end the +violence. It goes terribly wrong, and before the lovers know what's +happened, tragedy strikes and doesn't stop until the climactic and +heartbreaking ending. |
