diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2020-10-06 05:50:42 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-06 05:50:42 +0100 |
| commit | 72443babf9fde054ef2083bb4147dacbc35aa40f (patch) | |
| tree | a60a61e6591d641edcb24b18cf9f23e0de3fc1f2 | |
| parent | cef248ba491398a30061ba49fbc2a824116ae996 (diff) | |
| parent | a9457e1350312cc11afd75a63b0b70615cdef863 (diff) | |
| download | perlweeklychallenge-club-72443babf9fde054ef2083bb4147dacbc35aa40f.tar.gz perlweeklychallenge-club-72443babf9fde054ef2083bb4147dacbc35aa40f.tar.bz2 perlweeklychallenge-club-72443babf9fde054ef2083bb4147dacbc35aa40f.zip | |
Merge pull request #2452 from andemark/branch-for-challenge-081
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 | 10 | ||||
| -rw-r--r-- | challenge-081/mark-anderson/raku/file.txt | 15 |
3 files changed, 39 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..2d4ccb4aa7 --- /dev/null +++ b/challenge-081/mark-anderson/raku/ch-2.raku @@ -0,0 +1,10 @@ +unit sub MAIN($file); + +say freq-sort($file).join("\n\n"); + +sub freq-sort($file) { + my $bag = bag ($file.IO.slurp andthen S:g/<[."(),]>|\'s|\-\-/ /.words); + + gather take "{.key} {.value.sort}" + for $bag.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. |
