aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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];
+}