aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-239/zapwai/perl/ch-1.pl15
-rw-r--r--challenge-239/zapwai/perl/ch-2.pl24
2 files changed, 39 insertions, 0 deletions
diff --git a/challenge-239/zapwai/perl/ch-1.pl b/challenge-239/zapwai/perl/ch-1.pl
new file mode 100644
index 0000000000..6403aa7745
--- /dev/null
+++ b/challenge-239/zapwai/perl/ch-1.pl
@@ -0,0 +1,15 @@
+use v5.30;
+my @arr1 = ("ab","c");
+my @arr2 = ("a","bc");
+say "Input:\t \@arr1 = (". join(", ", @arr1) . ")";
+say "\t \@arr2 = (" . join(", ", @arr2) . ")";
+my $veracity = (paste(@arr1) eq paste(@arr2)) ? "True" : "False";
+say "Output: " . $veracity;
+sub paste {
+ my @a = @_;
+ my $word;
+ for (0 .. $#a) {
+ $word .= $a[$_];
+ }
+ $word
+}
diff --git a/challenge-239/zapwai/perl/ch-2.pl b/challenge-239/zapwai/perl/ch-2.pl
new file mode 100644
index 0000000000..18e7949b52
--- /dev/null
+++ b/challenge-239/zapwai/perl/ch-2.pl
@@ -0,0 +1,24 @@
+use v5.30;
+my @str = ("ad", "bd", "aaab", "baa", "badab");
+my $allowed = "ab";
+# @str = ("a", "b", "c", "ab", "ac", "bc", "abc");
+# my $allowed = "abc";
+# @str = ("cc", "acd", "b", "ba", "bac", "bad", "ac", "d");
+# my $allowed = "cad";
+my $count = 0;
+my @good = split "", $allowed;
+foreach my $word (@str) {
+ my @let = split "", $word;
+ my $cnt = 0;
+ letter: foreach my $l (@let) {
+ foreach my $g (@good) {
+ if ($l eq $g) {
+ $cnt++;
+ next letter;
+ }
+ }
+ }
+ $count++ if ($cnt == $#let + 1);
+}
+say "Input: \@str = (" . join(",",@str).")\n\t\$allowed = $allowed";
+say "Output: $count";