aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <Mohammad.Anwar@yahoo.com>2025-06-16 21:59:06 +0100
committerGitHub <noreply@github.com>2025-06-16 21:59:06 +0100
commite7ecff294dd186d69064b8a36f2d9065b19802dd (patch)
tree55cfea8b75cd7289e97904960c5d8d8258ef5d60
parentf93c993be82a0be23cf5663014d8e2e8059a8789 (diff)
parent3898bce7198df1752432e4fa099fd19637320b50 (diff)
downloadperlweeklychallenge-club-e7ecff294dd186d69064b8a36f2d9065b19802dd.tar.gz
perlweeklychallenge-club-e7ecff294dd186d69064b8a36f2d9065b19802dd.tar.bz2
perlweeklychallenge-club-e7ecff294dd186d69064b8a36f2d9065b19802dd.zip
Merge pull request #12194 from mahnkong/challenge-326
Challenge 326
-rw-r--r--challenge-326/mahnkong/perl/ch-1.pl14
-rw-r--r--challenge-326/mahnkong/perl/ch-2.pl21
2 files changed, 35 insertions, 0 deletions
diff --git a/challenge-326/mahnkong/perl/ch-1.pl b/challenge-326/mahnkong/perl/ch-1.pl
new file mode 100644
index 0000000000..bf1233afce
--- /dev/null
+++ b/challenge-326/mahnkong/perl/ch-1.pl
@@ -0,0 +1,14 @@
+use strict;
+use warnings;
+use feature 'signatures';
+use Test::More 'no_plan';
+use Time::Piece;
+
+sub run($date) {
+ my $time = Time::Piece->strptime($date,"%Y-%m-%d");
+ return localtime($time)->[7] + 1;
+}
+
+is(run('2025-02-02'), 33, "Example 1");
+is(run('2025-04-10'), 100, "Example 2");
+is(run('2025-09-07'), 250, "Example 3");
diff --git a/challenge-326/mahnkong/perl/ch-2.pl b/challenge-326/mahnkong/perl/ch-2.pl
new file mode 100644
index 0000000000..d0f4025d90
--- /dev/null
+++ b/challenge-326/mahnkong/perl/ch-2.pl
@@ -0,0 +1,21 @@
+use strict;
+use warnings;
+use feature 'signatures';
+use Test::More 'no_plan';
+
+sub run(@ints) {
+ return undef if scalar(@ints) % 2 != 0;
+
+ my @result;
+ while (scalar(@ints) > 0) {
+ my $m = shift @ints;
+ my $v = shift @ints;
+ push @result, $v for (1 .. $m);
+ }
+
+ return [ @result ];
+}
+
+is_deeply(run(1, 3, 2, 4), [3, 4, 4], "Example 1");
+is_deeply(run(1, 1, 2, 2), [1, 2, 2], "Example 2");
+is_deeply(run(3, 1, 3, 2), [1, 1, 1, 2, 2, 2], "Example 3");