aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <Mohammad.Anwar@yahoo.com>2023-11-13 17:34:33 +0000
committerGitHub <noreply@github.com>2023-11-13 17:34:33 +0000
commita6ad92cac5f8db69bed0c2c6284ae497090946a8 (patch)
tree52c70c64e18ce300804609855d70138a0c5e969b
parent81aef23b12cfbba69bf7fc2cb8493eadb2423722 (diff)
parentd79417d46337abf76cd36ff33e079bb3c1a3ba12 (diff)
downloadperlweeklychallenge-club-a6ad92cac5f8db69bed0c2c6284ae497090946a8.tar.gz
perlweeklychallenge-club-a6ad92cac5f8db69bed0c2c6284ae497090946a8.tar.bz2
perlweeklychallenge-club-a6ad92cac5f8db69bed0c2c6284ae497090946a8.zip
Merge pull request #9060 from zapwai/branch-for-243
Week 243
-rw-r--r--challenge-243/zapwai/perl/ch-1.pl17
-rw-r--r--challenge-243/zapwai/perl/ch-2.pl12
2 files changed, 29 insertions, 0 deletions
diff --git a/challenge-243/zapwai/perl/ch-1.pl b/challenge-243/zapwai/perl/ch-1.pl
new file mode 100644
index 0000000000..9bee74d994
--- /dev/null
+++ b/challenge-243/zapwai/perl/ch-1.pl
@@ -0,0 +1,17 @@
+use v5.30;
+my @nums = (1,3,2,3,1);
+#@nums = (2,4,3,5,1);
+my $output;
+my $cnt = 0;
+for my $i (0 .. $#nums - 1) {
+ for my $j ($i .. $#nums) {
+ if ( $nums[$i] > 2 * $nums[$j] ) {
+ $output .= "($i, $j) --> ($nums[$i], $nums[$j])\n";
+ $cnt++;
+ }
+ }
+}
+say "Input: \@nums = (" .join(", ",@nums).")";
+say "Output: $cnt";
+chomp $output;
+say $output;
diff --git a/challenge-243/zapwai/perl/ch-2.pl b/challenge-243/zapwai/perl/ch-2.pl
new file mode 100644
index 0000000000..2f9ac96005
--- /dev/null
+++ b/challenge-243/zapwai/perl/ch-2.pl
@@ -0,0 +1,12 @@
+use v5.30;
+my @nums = (2,5,9);
+#@nums = (7,7,7,7,7,7,7);
+my $cnt = 0;
+for my $n (@nums) {
+ for my $m (@nums) {
+ # say "($n, $m)" . (int $n/$m);
+ $cnt += (int $n/$m);
+ }
+}
+say "Input: \@nums = (".join(", ",@nums).")";
+say "Output: $cnt";