aboutsummaryrefslogtreecommitdiff
path: root/challenge-081
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-081')
-rw-r--r--challenge-081/abigail/input-1-12
-rw-r--r--challenge-081/abigail/input-1-22
-rw-r--r--challenge-081/abigail/output-1-1.exp2
-rw-r--r--challenge-081/abigail/output-1-2.exp1
-rw-r--r--challenge-081/abigail/perl/ch-1.pl37
5 files changed, 44 insertions, 0 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/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/perl/ch-1.pl b/challenge-081/abigail/perl/ch-1.pl
new file mode 100644
index 0000000000..840fc865f9
--- /dev/null
+++ b/challenge-081/abigail/perl/ch-1.pl
@@ -0,0 +1,37 @@
+#!/opt/perl/bin/perl
+
+use 5.032;
+
+use strict;
+use warnings;
+no warnings 'syntax';
+
+use experimental 'signatures';
+use experimental 'lexical_subs';
+
+chomp (my $str1 = <>);
+chomp (my $str2 = <>);
+
+#
+# Sort the strings by lenght, so $str1 isn't longer than $str2.
+#
+($str1, $str2) = ($str2, $str1) if length $str2 < length $str1;
+
+#
+# Find a substring which cannot be part of either string,
+# nor of its concatenation.
+#
+my $sep = "\x00" x (1 + length ($str1) + length ($str2));
+
+#
+# Now, use a regular expression to find common base strings.
+#
+$_ = "$str1$sep$str2";
+/^ (.+) \1* # Find base strings of $str1
+ $sep # Match the separator
+ \1+ $ # Must be base string for $str2
+ (?{say $1}) # Print it
+ (*FAIL) # Backtrack so we can try other base strings.
+/x;
+
+__END__