aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <Mohammad.Anwar@yahoo.com>2023-11-28 11:19:54 +0000
committerGitHub <noreply@github.com>2023-11-28 11:19:54 +0000
commit3a1382d9d05e817c2ebcac8d4243397f669aa006 (patch)
treea6f119b961ba6c88e9d73c09f5a15899d5f0d983
parent541452e81604ab1686842a9e80a06f521b691ebd (diff)
parent27232da67afa8341279a318f5d22591c44f5a611 (diff)
downloadperlweeklychallenge-club-3a1382d9d05e817c2ebcac8d4243397f669aa006.tar.gz
perlweeklychallenge-club-3a1382d9d05e817c2ebcac8d4243397f669aa006.tar.bz2
perlweeklychallenge-club-3a1382d9d05e817c2ebcac8d4243397f669aa006.zip
Merge pull request #9156 from zapwai/branch-for-245
Week 245
-rw-r--r--challenge-245/zapwai/perl/ch-1.pl9
-rw-r--r--challenge-245/zapwai/perl/ch-2.pl29
2 files changed, 38 insertions, 0 deletions
diff --git a/challenge-245/zapwai/perl/ch-1.pl b/challenge-245/zapwai/perl/ch-1.pl
new file mode 100644
index 0000000000..86820748f0
--- /dev/null
+++ b/challenge-245/zapwai/perl/ch-1.pl
@@ -0,0 +1,9 @@
+use v5.30;
+my @lang = ('perl', 'c', 'python');
+my @pop = (2, 1, 3);
+my @ans;
+foreach my $i (0 .. $#pop) {
+ $ans[$pop[$i] - 1] = $lang[$i];
+}
+say "Input : \@lang = @lang\n \t\@pop = @pop";
+say "Output: @ans";
diff --git a/challenge-245/zapwai/perl/ch-2.pl b/challenge-245/zapwai/perl/ch-2.pl
new file mode 100644
index 0000000000..e2acbbfd13
--- /dev/null
+++ b/challenge-245/zapwai/perl/ch-2.pl
@@ -0,0 +1,29 @@
+use v5.30;
+use Math::Combinatorics;
+use Algorithm::Permute;
+use List::Util;
+my @digits = (8,1,9);
+@digits = (8,6,7,1,0);
+my @poss;
+
+for my $cnt (1 .. @digits) {
+ my $comb = Math::Combinatorics->new(
+ count => $cnt,
+ data => [@digits]
+ );
+ while (my @combo = $comb->next_combination) {
+ my $p = Algorithm::Permute->new(\@combo);
+ while (my @perm = $p->next) {
+ my $num = join("", @perm);
+ push @poss, [@perm] if ($num % 3 == 0);
+ }
+ }
+}
+
+my $max = -1;
+for my $r (@poss) {
+ my $num = join("", @$r);
+ $max = $num if ($max < $num);
+}
+say "Input : \@digits = (" .join(", ",@digits).")";
+say "Output: $max";