aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorE. Choroba <choroba@matfyz.cz>2025-07-26 21:31:44 +0200
committerE. Choroba <choroba@matfyz.cz>2025-07-26 21:31:44 +0200
commit67b18ec3faa0300a8006b511d79a61409a573cea (patch)
treeb0b5e5df6caeba032289fefd480935338f0109ec
parent1ff2c9796a511d63231d3757acb27e4046a91fb2 (diff)
downloadperlweeklychallenge-club-67b18ec3faa0300a8006b511d79a61409a573cea.tar.gz
perlweeklychallenge-club-67b18ec3faa0300a8006b511d79a61409a573cea.tar.bz2
perlweeklychallenge-club-67b18ec3faa0300a8006b511d79a61409a573cea.zip
Add solutions to 332: Binary Date & Odd Letters by E. Choroba
-rwxr-xr-xchallenge-332/e-choroba/perl/ch-1.pl14
-rwxr-xr-xchallenge-332/e-choroba/perl/ch-2.pl17
2 files changed, 31 insertions, 0 deletions
diff --git a/challenge-332/e-choroba/perl/ch-1.pl b/challenge-332/e-choroba/perl/ch-1.pl
new file mode 100755
index 0000000000..0d6f978404
--- /dev/null
+++ b/challenge-332/e-choroba/perl/ch-1.pl
@@ -0,0 +1,14 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+use experimental qw( signatures );
+
+sub binary_date($date) {
+ join '-', map sprintf('%b', $_), split /-/, $date
+}
+
+use Test::More tests => 3;
+
+is binary_date('2025-07-26'), '11111101001-111-11010', 'Example 1';
+is binary_date('2000-02-02'), '11111010000-10-10', 'Example 2';
+is binary_date('2024-12-31'), '11111101000-1100-11111', 'Example 3';
diff --git a/challenge-332/e-choroba/perl/ch-2.pl b/challenge-332/e-choroba/perl/ch-2.pl
new file mode 100755
index 0000000000..29654a9efd
--- /dev/null
+++ b/challenge-332/e-choroba/perl/ch-2.pl
@@ -0,0 +1,17 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+use experimental qw( signatures );
+
+sub odd_letters($str) {
+ my %letter;
+ ++$letter{$_} for split //, $str;
+ return ! grep 0 == $_ % 2, values %letter
+}
+
+use Test2::V0;
+plan(3);
+
+is odd_letters('weekly'), bool(0), 'Example 1';
+is odd_letters('perl'), bool(1), 'Example 2';
+is odd_letters('challenge'), bool(0), 'Example 3';