aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2020-10-06 06:04:54 +0100
committerGitHub <noreply@github.com>2020-10-06 06:04:54 +0100
commitac705ef2b84288311302dfb6337437a8cb1ac000 (patch)
treed486e604239d26b1bed03564d81f6c4641004c84
parent7d4af6ae36d88dd17da37fa66dcfc63474b0b504 (diff)
parent93f04638ce7a44b303b9fb42cfcbd24995d40160 (diff)
downloadperlweeklychallenge-club-ac705ef2b84288311302dfb6337437a8cb1ac000.tar.gz
perlweeklychallenge-club-ac705ef2b84288311302dfb6337437a8cb1ac000.tar.bz2
perlweeklychallenge-club-ac705ef2b84288311302dfb6337437a8cb1ac000.zip
Merge pull request #2454 from Scimon/master
Morning
-rw-r--r--challenge-081/simon-proctor/raku/ch-1.raku13
-rw-r--r--challenge-081/simon-proctor/raku/ch-2.raku16
-rw-r--r--challenge-081/simon-proctor/raku/input3
3 files changed, 32 insertions, 0 deletions
diff --git a/challenge-081/simon-proctor/raku/ch-1.raku b/challenge-081/simon-proctor/raku/ch-1.raku
new file mode 100644
index 0000000000..951677af6e
--- /dev/null
+++ b/challenge-081/simon-proctor/raku/ch-1.raku
@@ -0,0 +1,13 @@
+#!/usr/bin/env raku
+
+use v6;
+
+#| Given two strings find the common root strings
+sub MAIN ( Str $a, Str $b ) {
+ .say for ( get-roots($a) (&) get-roots($b) ).keys;
+}
+
+sub get-roots( Str $a ) {
+ ($a ~~ m:ex/^ (.+?) $0* $/).map(*[0].Str);
+}
+
diff --git a/challenge-081/simon-proctor/raku/ch-2.raku b/challenge-081/simon-proctor/raku/ch-2.raku
new file mode 100644
index 0000000000..898a5b2af7
--- /dev/null
+++ b/challenge-081/simon-proctor/raku/ch-2.raku
@@ -0,0 +1,16 @@
+#!/usr/bin/env raku
+
+use v6;
+
+#| Read the given input file (default "input") and give a litst of
+#| words grouped by count.
+sub MAIN ( Str $input-file = "input" ) {
+ my %map;
+ for $input-file.IO.words.map( -> $x is copy { $x ~~ s:g/ "."|'"'|"("|")"|","|"'s"|"--" //; $x } ).Bag.antipairs -> $p {
+ %map{$p.key} //= [];
+ %map{$p.key}.push($p.value);
+ }
+ for %map.keys.sort {
+ say "$_ {%map{$_}.sort.join(" ")}";
+ }
+}
diff --git a/challenge-081/simon-proctor/raku/input b/challenge-081/simon-proctor/raku/input
new file mode 100644
index 0000000000..37001629ad
--- /dev/null
+++ b/challenge-081/simon-proctor/raku/input
@@ -0,0 +1,3 @@
+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.