diff options
| author | David Ferrone <zapwai@gmail.com> | 2023-11-13 12:00:57 -0500 |
|---|---|---|
| committer | David Ferrone <zapwai@gmail.com> | 2023-11-13 12:00:57 -0500 |
| commit | d79417d46337abf76cd36ff33e079bb3c1a3ba12 (patch) | |
| tree | 7b0ab49dfcf7e979a3182ae393bfc37bedd533b9 | |
| parent | aeed5ae2bdafdcf14de24d172392278b8ba0b44f (diff) | |
| download | perlweeklychallenge-club-d79417d46337abf76cd36ff33e079bb3c1a3ba12.tar.gz perlweeklychallenge-club-d79417d46337abf76cd36ff33e079bb3c1a3ba12.tar.bz2 perlweeklychallenge-club-d79417d46337abf76cd36ff33e079bb3c1a3ba12.zip | |
Week 243
| -rw-r--r-- | challenge-243/zapwai/perl/ch-1.pl | 17 | ||||
| -rw-r--r-- | challenge-243/zapwai/perl/ch-2.pl | 12 |
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"; |
