aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-338/zapwai/perl/ch-1.pl15
-rw-r--r--challenge-338/zapwai/perl/ch-2.pl18
2 files changed, 33 insertions, 0 deletions
diff --git a/challenge-338/zapwai/perl/ch-1.pl b/challenge-338/zapwai/perl/ch-1.pl
new file mode 100644
index 0000000000..89d96832f3
--- /dev/null
+++ b/challenge-338/zapwai/perl/ch-1.pl
@@ -0,0 +1,15 @@
+use v5.38;
+use List::Util "sum", "max";
+
+sub proc(@matrix) {
+ my @sum;
+ for my $i (0 .. $#matrix) {
+ push @sum, sum(@{$matrix[$i]});
+ }
+ say "Output: " . max(@sum);
+}
+
+my @matrix = ([4, 4, 4, 4],
+ [10, 0, 0, 0],
+ [2, 2, 2, 9]);
+proc(@matrix);
diff --git a/challenge-338/zapwai/perl/ch-2.pl b/challenge-338/zapwai/perl/ch-2.pl
new file mode 100644
index 0000000000..01b5d7b7e4
--- /dev/null
+++ b/challenge-338/zapwai/perl/ch-2.pl
@@ -0,0 +1,18 @@
+use v5.38;
+use List::Util qw(min max);
+
+sub proc($ref1, $ref2) {
+ my @a1 = @$ref1;
+ my @a2 = @$ref2;
+ my ($max1, $max2) = (max(@a1), max(@a2));
+ my ($min1, $min2) = (min(@a1), min(@a2));
+ my ($diff1, $diff2) = (
+ $max2 - $min1,
+ $max1 - $min2
+ );
+ say "Output: " . max($diff1, $diff2);
+}
+
+my @arr1 = (4,5,7);
+my @arr2 = (9,1,3,4);
+proc(\@arr1, \@arr2);