diff options
| -rw-r--r-- | challenge-328/wlmb/blog.txt | 1 | ||||
| -rwxr-xr-x | challenge-328/wlmb/perl/ch-1.pl | 24 | ||||
| -rwxr-xr-x | challenge-328/wlmb/perl/ch-2.pl | 17 |
3 files changed, 42 insertions, 0 deletions
diff --git a/challenge-328/wlmb/blog.txt b/challenge-328/wlmb/blog.txt new file mode 100644 index 0000000000..5ed44b71c3 --- /dev/null +++ b/challenge-328/wlmb/blog.txt @@ -0,0 +1 @@ +https://wlmb.github.io/2025/07/03/PWC328/ diff --git a/challenge-328/wlmb/perl/ch-1.pl b/challenge-328/wlmb/perl/ch-1.pl new file mode 100755 index 0000000000..9cffa7b2a8 --- /dev/null +++ b/challenge-328/wlmb/perl/ch-1.pl @@ -0,0 +1,24 @@ +#!/usr/bin/env perl +# Perl weekly challenge 328 +# Task 1: Replace all ? +# +# See https://wlmb.github.io/2025/07/03/PWC328/#task-1-replace-all-? + +use v5.36; +die <<~"FIN" unless @ARGV; + Usage: $0 S1 S2... + to replace ? by lowercase letters in the lowercase strings S1 S2... + so that no letter repeats. + FIN +for(@ARGV){ + say "Expected only lowercase letters and ?'s" unless /^[a-z?]+$/; + say("Expected no repeating letters in string: $_"), next if /([a-z])\1/; + my $in=$_; + 1 while s/(.?)(\?)(.?)/replace($1, $3)/e; + say "$in -> $_"; +} +sub replace($x, $z){ + my $y="a"; + ++$y while $y eq $x or $y eq $z; + "$1$y$3" +} diff --git a/challenge-328/wlmb/perl/ch-2.pl b/challenge-328/wlmb/perl/ch-2.pl new file mode 100755 index 0000000000..3c1bb357c5 --- /dev/null +++ b/challenge-328/wlmb/perl/ch-2.pl @@ -0,0 +1,17 @@ +#!/usr/bin/env perl +# Perl weekly challenge 328 +# Task 2: Good String +# +# See https://wlmb.github.io/2025/07/03/PWC328/#task-2-good-string +use v5.36; +die <<~"FIN" unless @ARGV; + Usage: $0 S1 S2... + to convert the strings S1 S2... into good strings + without any lowercase (uppercase) letter adjacent to the corresponding + uppercase (lowercase) letter. + FIN +for(@ARGV){ + my $in=$_; + 1 while(s/([[:alpha:]])(??{my $l=lc($1); $l eq $1? uc($1):lc($1)})//); + say"$in->$_"; +} |
