aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuis Mochan <mochan@fis.unam.mx>2025-09-22 10:43:31 -0600
committerLuis Mochan <mochan@fis.unam.mx>2025-09-22 10:43:31 -0600
commit6d981be50d2cac782017a0becf2e63dbf2b1580b (patch)
tree5ae7c1f57326d7b323c6417354dc6675cd9f183e
parentc4e70544812c339e0344ad3127de18a5dbf98c34 (diff)
downloadperlweeklychallenge-club-6d981be50d2cac782017a0becf2e63dbf2b1580b.tar.gz
perlweeklychallenge-club-6d981be50d2cac782017a0becf2e63dbf2b1580b.tar.bz2
perlweeklychallenge-club-6d981be50d2cac782017a0becf2e63dbf2b1580b.zip
Solve PWC340
-rw-r--r--challenge-340/wlmb/blog.txt1
-rwxr-xr-xchallenge-340/wlmb/perl/ch-1.pl15
-rwxr-xr-xchallenge-340/wlmb/perl/ch-2.pl13
3 files changed, 29 insertions, 0 deletions
diff --git a/challenge-340/wlmb/blog.txt b/challenge-340/wlmb/blog.txt
new file mode 100644
index 0000000000..ad835ab5f2
--- /dev/null
+++ b/challenge-340/wlmb/blog.txt
@@ -0,0 +1 @@
+https://wlmb.github.io/2025/09/22/PWC340/
diff --git a/challenge-340/wlmb/perl/ch-1.pl b/challenge-340/wlmb/perl/ch-1.pl
new file mode 100755
index 0000000000..9da0302551
--- /dev/null
+++ b/challenge-340/wlmb/perl/ch-1.pl
@@ -0,0 +1,15 @@
+#!/usr/bin/env perl
+# Perl weekly challenge 340
+# Task 1: Duplicate Removals
+#
+# See https://wlmb.github.io/2025/09/22/PWC340/#task-1-duplicate-removals
+use v5.36;
+die <<~"FIN" unless @ARGV;
+ Usage: $0 S0 S1...
+ to remove adjacent duplicate characters from the strings S0 S1...
+ FIN
+for(@ARGV){
+ my $input=$_;
+ 1 while s/(.)\1//g;
+ say "$input -> $_"
+}
diff --git a/challenge-340/wlmb/perl/ch-2.pl b/challenge-340/wlmb/perl/ch-2.pl
new file mode 100755
index 0000000000..5104134488
--- /dev/null
+++ b/challenge-340/wlmb/perl/ch-2.pl
@@ -0,0 +1,13 @@
+#!/usr/bin/env perl
+# Perl weekly challenge 340
+# Task 2: Ascending Numbers
+#
+# See https://wlmb.github.io/2025/09/22/PWC340/#task-2-ascending-numbers
+use v5.36;
+use List::Util qw(uniq);
+for(@ARGV){
+ my @splitted= grep {length>0} split/[^0-9]+/; # split on non digits. May let some badly formed strings through
+ my @sorted = sort {$a<=>$b} uniq @splitted; # remove duplicates and numerically sort all numbers
+ my $result = "@sorted" eq "@splitted"?"True":"False"; # join and compare as strings
+ say "$_ -> ", $result
+}