diff options
| author | Myoungjin JEON <jeongoon@gmail.com> | 2020-10-15 00:04:11 +1100 |
|---|---|---|
| committer | Myoungjin JEON <jeongoon@gmail.com> | 2020-10-15 00:04:11 +1100 |
| commit | dd71532a73981ec613c8c61d99fa4bbd3f3fd79c (patch) | |
| tree | 70b1b5c1613f51461bb27f6b4aa49ba8b5efa78e /challenge-081 | |
| parent | 99053d27c19ab6baee10484e8de730527333ddde (diff) | |
| parent | a86e289ff2bb02e7c579be9175c92f2667168a28 (diff) | |
| download | perlweeklychallenge-club-dd71532a73981ec613c8c61d99fa4bbd3f3fd79c.tar.gz perlweeklychallenge-club-dd71532a73981ec613c8c61d99fa4bbd3f3fd79c.tar.bz2 perlweeklychallenge-club-dd71532a73981ec613c8c61d99fa4bbd3f3fd79c.zip | |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'challenge-081')
109 files changed, 3437 insertions, 70 deletions
diff --git a/challenge-081/abigail/input-1-1 b/challenge-081/abigail/input-1-1 new file mode 100644 index 0000000000..bcb118a7c2 --- /dev/null +++ b/challenge-081/abigail/input-1-1 @@ -0,0 +1,2 @@ +abcdabcd +abcdabcdabcdabcd diff --git a/challenge-081/abigail/input-1-2 b/challenge-081/abigail/input-1-2 new file mode 100644 index 0000000000..0917019ba6 --- /dev/null +++ b/challenge-081/abigail/input-1-2 @@ -0,0 +1,2 @@ +aaa +aa diff --git a/challenge-081/abigail/input-2-1 b/challenge-081/abigail/input-2-1 new file mode 100644 index 0000000000..f7786e4f1b --- /dev/null +++ b/challenge-081/abigail/input-2-1 @@ -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. diff --git a/challenge-081/abigail/output-1-1.exp b/challenge-081/abigail/output-1-1.exp new file mode 100644 index 0000000000..ddf5cedb9f --- /dev/null +++ b/challenge-081/abigail/output-1-1.exp @@ -0,0 +1,2 @@ +abcdabcd +abcd diff --git a/challenge-081/abigail/output-1-2.exp b/challenge-081/abigail/output-1-2.exp new file mode 100644 index 0000000000..7898192261 --- /dev/null +++ b/challenge-081/abigail/output-1-2.exp @@ -0,0 +1 @@ +a diff --git a/challenge-081/abigail/output-2-1.exp b/challenge-081/abigail/output-2-1.exp new file mode 100644 index 0000000000..014ffe9684 --- /dev/null +++ b/challenge-081/abigail/output-2-1.exp @@ -0,0 +1,9 @@ +1 But City It Jet Juliet Latino New Romeo Side Story Their Then West York adaptation any anything at award-winning away become before begin best classic climactic coexist control dance do doesn't end ending escalates families feuding form former friend gains gangs goes happened hatred heartbreaking highway hoping in know love lovers meet meeting neither no one plan planning point romantic rumble run secret sends sister streets strikes terribly their two under understanding until violence warring what when where white whoever wins with wrong younger + +2 Bernardo Jets Riff Sharks The by it led tragedy + +3 Maria Tony a can of stop + +4 to + +9 and the diff --git a/challenge-081/abigail/perl/ch-1.pl b/challenge-081/abigail/perl/ch-1.pl new file mode 100644 index 0000000000..39e62fc635 --- /dev/null +++ b/challenge-081/abigail/perl/ch-1.pl @@ -0,0 +1,46 @@ +#!/opt/perl/bin/perl + +# +# You are given 2 strings, $A and $B. +# +# Write a script to find out common base strings in $A and $B. +# +# A substring of a string $S is called base string if repeated +# concatenation of the substring results in the string. +# + +use 5.032; + +use strict; +use warnings; +no warnings 'syntax'; + +use experimental 'signatures'; +use experimental 'lexical_subs'; + +chomp (my $A = <>); +chomp (my $B = <>); + +# +# Sort the strings by lenght, so $A isn't longer than $B. +# +($A, $B) = ($B, $A) if length $B < length $A; + +# +# Find a substring which cannot be part of either string, +# nor of its concatenation. +# +my $sep = "\x00" x (1 + length ($A) + length ($B)); + +# +# Now, use a regular expression to find common base strings. +# +$_ = "$A$sep$B"; +/^ (.+) \1* # Find base strings of $A + $sep # Match the separator + \1+ $ # Must be base string for $B + (?{say $1}) # Print it + (*FAIL) # Backtrack so we can try other base strings. |
