From f28dd62af10e7bcc108fccb680cc06777d89d850 Mon Sep 17 00:00:00 2001 From: Luis Mochan Date: Mon, 14 Jul 2025 11:10:50 -0600 Subject: Solve PWC 330 --- challenge-330/wlmb/blog.txt | 1 + challenge-330/wlmb/perl/ch-1.pl | 20 ++++++++++++++++++++ challenge-330/wlmb/perl/ch-2.pl | 12 ++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 challenge-330/wlmb/blog.txt create mode 100755 challenge-330/wlmb/perl/ch-1.pl create mode 100755 challenge-330/wlmb/perl/ch-2.pl diff --git a/challenge-330/wlmb/blog.txt b/challenge-330/wlmb/blog.txt new file mode 100644 index 0000000000..9a2eddb4c9 --- /dev/null +++ b/challenge-330/wlmb/blog.txt @@ -0,0 +1 @@ +https://wlmb.github.io/2025/07/14/PWC330/ diff --git a/challenge-330/wlmb/perl/ch-1.pl b/challenge-330/wlmb/perl/ch-1.pl new file mode 100755 index 0000000000..3821ff49a1 --- /dev/null +++ b/challenge-330/wlmb/perl/ch-1.pl @@ -0,0 +1,20 @@ +#!/usr/bin/env perl +# Perl weekly challenge 330 +# Task 1: Clear Digits +# +# See https://wlmb.github.io/2025/07/14/PWC330/#task-1-clear-digits +use v5.36; +die <<~"FIN" unless @ARGV; + Usage: $0 S1 S2... + to repeatedly remove digits from the string Sn, together with the closest + non-digit to its left. + Only lowercase letters and digits are allowed in the strings. + FIN +for(@ARGV){ + my $input=$_; + say("Only digits and lowercase letters allowed: $input"), next + unless /^[a-z0-9]*$/; + 1 while s/[a-z][0-9]//; #strip all letter-digit pairs + say("Couldn't strip all digits: $input -> $_"), next if /[0-9]/; + say "$input -> $_"; +} diff --git a/challenge-330/wlmb/perl/ch-2.pl b/challenge-330/wlmb/perl/ch-2.pl new file mode 100755 index 0000000000..da3d717b33 --- /dev/null +++ b/challenge-330/wlmb/perl/ch-2.pl @@ -0,0 +1,12 @@ +#!/usr/bin/env perl +# Perl weekly challenge 330 +# Task 2: Title Capital +# +# See https://wlmb.github.io/2025/07/14/PWC330/#task-2-title-capital +use v5.36; +die <<~"FIN" unless @ARGV; + Usage: $0 S1 S2... + to convert words in the space-separated strings Sn to titlecase + or to lowercase if their length exceeds or not 2 characters. + FIN +say join " ", map {(length($_) >2 && ucfirst)||$_} split " ", lc for @ARGV; -- cgit