aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Mahnke <andreas.mahnke@leuphana.de>2025-06-16 14:31:31 +0200
committerAndreas Mahnke <andreas.mahnke@leuphana.de>2025-06-16 14:31:31 +0200
commit3898bce7198df1752432e4fa099fd19637320b50 (patch)
tree407c758db81d950523bff5e22f6cf3b62e8c5197
parent26cfae99bb0a2fdf9710bcc51e8abc8d7ed627f6 (diff)
downloadperlweeklychallenge-club-3898bce7198df1752432e4fa099fd19637320b50.tar.gz
perlweeklychallenge-club-3898bce7198df1752432e4fa099fd19637320b50.tar.bz2
perlweeklychallenge-club-3898bce7198df1752432e4fa099fd19637320b50.zip
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");