aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <Mohammad.Anwar@yahoo.com>2025-07-31 11:10:48 +0100
committerGitHub <noreply@github.com>2025-07-31 11:10:48 +0100
commit6f076706e712b0f9af41e7aef2698d4dda87f8ae (patch)
tree1ebdf7d87f8ae178980e98a404d6b97ce292f489
parent0eccd4e8ccaa56228c109dce73524dcd314062a0 (diff)
parente8e55906a1cd5d34c20602238a878c960f2b34c8 (diff)
downloadperlweeklychallenge-club-6f076706e712b0f9af41e7aef2698d4dda87f8ae.tar.gz
perlweeklychallenge-club-6f076706e712b0f9af41e7aef2698d4dda87f8ae.tar.bz2
perlweeklychallenge-club-6f076706e712b0f9af41e7aef2698d4dda87f8ae.zip
Merge pull request #12415 from pjcs00/wk332
Week 332 - Base 2 dates and odd words
-rw-r--r--challenge-332/peter-campbell-smith/blog.txt1
-rwxr-xr-xchallenge-332/peter-campbell-smith/perl/ch-1.pl23
-rwxr-xr-xchallenge-332/peter-campbell-smith/perl/ch-2.pl35
3 files changed, 59 insertions, 0 deletions
diff --git a/challenge-332/peter-campbell-smith/blog.txt b/challenge-332/peter-campbell-smith/blog.txt
new file mode 100644
index 0000000000..6b1eb88ebc
--- /dev/null
+++ b/challenge-332/peter-campbell-smith/blog.txt
@@ -0,0 +1 @@
+http://ccgi.campbellsmiths.force9.co.uk/challenge/332
diff --git a/challenge-332/peter-campbell-smith/perl/ch-1.pl b/challenge-332/peter-campbell-smith/perl/ch-1.pl
new file mode 100755
index 0000000000..9ffff12a51
--- /dev/null
+++ b/challenge-332/peter-campbell-smith/perl/ch-1.pl
@@ -0,0 +1,23 @@
+#!/usr/bin/perl
+
+# Blog: http://ccgi.campbellsmiths.force9.co.uk/challenge
+
+use v5.26; # The Weekly Challenge - 2025-07-28
+use utf8; # Week 332 - task 1 - Binary date
+use warnings; # Peter Campbell Smith
+binmode STDOUT, ':utf8';
+use Encode;
+
+binary_date('2025-07-28');
+binary_date('1947-11-09');
+binary_date('8191-07-31');
+binary_date('2730-02-21');
+
+sub binary_date {
+
+ say qq[\nInput: \$date = '$_[0]'];
+ say qq[Output: ] . sprintf("'%b-%b-%b'",
+ substr($_[0], 0, 4), substr($_[0], 5, 2),
+ substr($_[0], 8, 2));
+}
+
diff --git a/challenge-332/peter-campbell-smith/perl/ch-2.pl b/challenge-332/peter-campbell-smith/perl/ch-2.pl
new file mode 100755
index 0000000000..cac158d041
--- /dev/null
+++ b/challenge-332/peter-campbell-smith/perl/ch-2.pl
@@ -0,0 +1,35 @@
+#!/usr/bin/perl
+
+# Blog: http://ccgi.campbellsmiths.force9.co.uk/challenge
+
+use v5.26; # The Weekly Challenge - 2025-07-28
+use utf8; # Week 332 - task 2 - Odd letters
+use warnings; # Peter Campbell Smith
+binmode STDOUT, ':utf8';
+use Encode;
+
+odd_letters('weekly');
+odd_letters('You are given a string');
+odd_letters('a bBb ccCcc dddDddd eeeeEeeee');
+odd_letters('supercalifragilisticexpialidocious');
+odd_letters('12345 +=-*<>');
+
+sub odd_letters {
+
+ my (%counts, $j);
+
+ # initialise
+ say qq[\nInput: \$str = '$_[0]'];
+
+ # count occurrences of each unique letter
+ $counts{$_} ++ for split('', lc($_[0]));
+
+ # see if the counts of letters are all odd
+ for $j (keys %counts) {
+ next if ($counts{$j} & 1 or $j !~ m|[a-z]|);
+ say qq[Output: false ('$j' occurs $counts{$j} times)];
+ return;
+ }
+
+ say qq[Output: true];
+}