aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-082/adam-russell/blog.txt1
-rw-r--r--challenge-082/adam-russell/perl/ch-2.pl34
2 files changed, 35 insertions, 0 deletions
diff --git a/challenge-082/adam-russell/blog.txt b/challenge-082/adam-russell/blog.txt
new file mode 100644
index 0000000000..2c0a23f34b
--- /dev/null
+++ b/challenge-082/adam-russell/blog.txt
@@ -0,0 +1 @@
+http://www.rabbitfarm.com/cgi-bin/blosxom/2020/10/18#pwc082
diff --git a/challenge-082/adam-russell/perl/ch-2.pl b/challenge-082/adam-russell/perl/ch-2.pl
new file mode 100644
index 0000000000..9a728fc056
--- /dev/null
+++ b/challenge-082/adam-russell/perl/ch-2.pl
@@ -0,0 +1,34 @@
+use strict;
+use warnings;
+##
+# You are given 3 strings; $A, $B and $C.
+# Write a script to check if $C is created by interleave $A and $B.
+# Print 1 if check is success otherwise 0.
+##
+sub find_remove{
+ my($s, $x) = @_;
+ my $i = index($s, $x);
+ if($i != -1){
+ substr $s, $i, length($x), "";
+ return $s;
+ }
+ return undef;
+}
+MAIN:{
+ my $A = "XY";
+ my $B = "X";
+ my $C = "XXY";
+ my $s = find_remove($C, $A);
+ if($s && $s eq $B){
+ print "1\n";
+ exit;
+ }
+ else{
+ $s = find_remove($C, $B);
+ if($s && $s eq $A){
+ print "1\n";
+ exit;
+ }
+ }
+ print "0\n";
+} \ No newline at end of file