From 67b18ec3faa0300a8006b511d79a61409a573cea Mon Sep 17 00:00:00 2001 From: "E. Choroba" Date: Sat, 26 Jul 2025 21:31:44 +0200 Subject: Add solutions to 332: Binary Date & Odd Letters by E. Choroba --- challenge-332/e-choroba/perl/ch-1.pl | 14 ++++++++++++++ challenge-332/e-choroba/perl/ch-2.pl | 17 +++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100755 challenge-332/e-choroba/perl/ch-1.pl create mode 100755 challenge-332/e-choroba/perl/ch-2.pl 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'; -- cgit