aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuis Mochan <mochan@fis.unam.mx>2025-02-02 20:16:25 -0600
committerLuis Mochan <mochan@fis.unam.mx>2025-02-02 20:16:25 -0600
commitee4fd04a9f90a1c574f49f4eb757fc565b68f935 (patch)
tree83845a20837f02e2061fd4592b1cff274d9c78e0
parent75cad926933996bff61b6684c63344fddbb4ea79 (diff)
downloadperlweeklychallenge-club-ee4fd04a9f90a1c574f49f4eb757fc565b68f935.tar.gz
perlweeklychallenge-club-ee4fd04a9f90a1c574f49f4eb757fc565b68f935.tar.bz2
perlweeklychallenge-club-ee4fd04a9f90a1c574f49f4eb757fc565b68f935.zip
SOlve PWC307
-rw-r--r--challenge-307/wlmb/blog.txt1
-rwxr-xr-xchallenge-307/wlmb/perl/ch-1.pl14
-rwxr-xr-xchallenge-307/wlmb/perl/ch-2.pl20
3 files changed, 35 insertions, 0 deletions
diff --git a/challenge-307/wlmb/blog.txt b/challenge-307/wlmb/blog.txt
new file mode 100644
index 0000000000..050e267b74
--- /dev/null
+++ b/challenge-307/wlmb/blog.txt
@@ -0,0 +1 @@
+https://wlmb.github.io/2025/02/02/PWC307/
diff --git a/challenge-307/wlmb/perl/ch-1.pl b/challenge-307/wlmb/perl/ch-1.pl
new file mode 100755
index 0000000000..d18d731ad8
--- /dev/null
+++ b/challenge-307/wlmb/perl/ch-1.pl
@@ -0,0 +1,14 @@
+#!/usr/bin/env perl
+# Perl weekly challenge 307
+# Task 1: Check Order
+#
+# See https://wlmb.github.io/2025/02/02/PWC307/#task-1-check-order
+use v5.36;
+die <<~"FIN" unless @ARGV;
+ Usage: $0 N0 N1...
+ to find the indices where the array N0 N1... differs from its ordered self.
+ FIN
+my @ordered = sort {$a <=> $b} @ARGV;
+my @result;
+$ordered[$_]!=$ARGV[$_] && push @result, $_ for 0..@ordered-1;
+say "@ARGV -> @result";
diff --git a/challenge-307/wlmb/perl/ch-2.pl b/challenge-307/wlmb/perl/ch-2.pl
new file mode 100755
index 0000000000..bd1cbc039a
--- /dev/null
+++ b/challenge-307/wlmb/perl/ch-2.pl
@@ -0,0 +1,20 @@
+#!/usr/bin/env perl
+# Perl weekly challenge 307
+# Task 2: Find Anagrams
+#
+# See https://wlmb.github.io/2025/02/02/PWC307/#task-2-find-anagrams
+use v5.36;
+die <<~"FIN" unless @ARGV;
+ Usage: $0 W0 W1 W2
+ to count anagram equivalence classes mong the words Wi.
+ FIN
+use List::Util qw(uniq);
+say "@ARGV -> ",
+ 0 + uniq
+ map {
+ my %hash;
+ $hash{lc $_}++ for split "";
+ join "", map {
+ $_, $hash{$_}
+ }sort keys %hash
+ } @ARGV;