aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuis Mochan <mochan@fis.unam.mx>2025-07-07 08:39:09 -0600
committerLuis Mochan <mochan@fis.unam.mx>2025-07-07 08:39:09 -0600
commit30cd4b99c7485a20a5e717da062cf92e9292b050 (patch)
treef6ca07d92ee6c9a3a24844865d1f8d8cb465feda
parentbd7fce4bd5d085c209a213f2daca1e79799c9e87 (diff)
downloadperlweeklychallenge-club-30cd4b99c7485a20a5e717da062cf92e9292b050.tar.gz
perlweeklychallenge-club-30cd4b99c7485a20a5e717da062cf92e9292b050.tar.bz2
perlweeklychallenge-club-30cd4b99c7485a20a5e717da062cf92e9292b050.zip
Solve PWC329
-rw-r--r--challenge-329/wlmb/blog.txt1
-rwxr-xr-xchallenge-329/wlmb/perl/ch-1.pl15
-rwxr-xr-xchallenge-329/wlmb/perl/ch-2.pl19
3 files changed, 35 insertions, 0 deletions
diff --git a/challenge-329/wlmb/blog.txt b/challenge-329/wlmb/blog.txt
new file mode 100644
index 0000000000..963c60e58c
--- /dev/null
+++ b/challenge-329/wlmb/blog.txt
@@ -0,0 +1 @@
+https://wlmb.github.io/2025/07/07/PWC329/
diff --git a/challenge-329/wlmb/perl/ch-1.pl b/challenge-329/wlmb/perl/ch-1.pl
new file mode 100755
index 0000000000..e9fe7fcc0a
--- /dev/null
+++ b/challenge-329/wlmb/perl/ch-1.pl
@@ -0,0 +1,15 @@
+#!/usr/bin/env perl
+# Perl weekly challenge 329
+# Task 1: Counter Integers
+#
+# See https://wlmb.github.io/2025/07/07/PWC329/#task-1-counter-integers
+use v5.36;
+use List::Util qw(uniqint);
+die <<~"FIN" unless @ARGV;
+ Usage: $0 S1 S2...
+ to find distinct integers within the strings Sn.
+ FIN
+for(@ARGV){
+ say("Only lowercase letters and digits allowed: $_"), next unless /^[a-z0-9]*$/;
+ say "$_ -> ", join " ", uniqint grep {!/^$/} split /[a-z]+/, $_;
+}
diff --git a/challenge-329/wlmb/perl/ch-2.pl b/challenge-329/wlmb/perl/ch-2.pl
new file mode 100755
index 0000000000..33053c7958
--- /dev/null
+++ b/challenge-329/wlmb/perl/ch-2.pl
@@ -0,0 +1,19 @@
+#!/usr/bin/env perl
+# Perl weekly challenge 329
+# Task 2: Nice String
+#
+# See https://wlmb.github.io/2025/07/07/PWC329/#task-2-nice-string
+use v5.36;
+use List::UtilsBy qw(max_by);
+say "$_ -> ",max_by {length} /(.+)(??{nice($1)?"(*ACCEPT)":"(*FAIL)"})/g for @ARGV;
+sub nice($s){
+ for($s){ # set the topic
+ while(1){
+ return 1 if /^$/; # null strings are nice
+ /^(.)(.*)/; # capture first character and rest
+ my ($lc, $UC)=(lc($1), uc($1));
+ return 0 unless /$lc/ && /$UC/; # check both cases are present in string
+ s/$lc|$UC//g; # remove already tested letters
+ }
+ }
+}