aboutsummaryrefslogtreecommitdiff
path: root/challenge-307
diff options
context:
space:
mode:
authorLuis Mochan <mochan@fis.unam.mx>2025-02-08 13:28:46 -0600
committerLuis Mochan <mochan@fis.unam.mx>2025-02-08 13:28:46 -0600
commit0c5eabd24392eb2c165626893db51818437e4ff2 (patch)
treebe06effce6d3adf63f65844a065c6b9700178b8d /challenge-307
parent9da701c4cdcd5e30f92fc90201187fee65604a8a (diff)
downloadperlweeklychallenge-club-0c5eabd24392eb2c165626893db51818437e4ff2.tar.gz
perlweeklychallenge-club-0c5eabd24392eb2c165626893db51818437e4ff2.tar.bz2
perlweeklychallenge-club-0c5eabd24392eb2c165626893db51818437e4ff2.zip
Correct error.
Diffstat (limited to 'challenge-307')
-rwxr-xr-xchallenge-307/wlmb/perl/ch-2.pl12
-rwxr-xr-xchallenge-307/wlmb/perl/ch-2a.pl21
2 files changed, 27 insertions, 6 deletions
diff --git a/challenge-307/wlmb/perl/ch-2.pl b/challenge-307/wlmb/perl/ch-2.pl
index bd1cbc039a..df08ca9115 100755
--- a/challenge-307/wlmb/perl/ch-2.pl
+++ b/challenge-307/wlmb/perl/ch-2.pl
@@ -6,15 +6,15 @@
use v5.36;
die <<~"FIN" unless @ARGV;
Usage: $0 W0 W1 W2
- to count anagram equivalence classes mong the words Wi.
+ to count anagram equivalence classes among 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
+ my %hash;
+ $hash{lc $_}++ for split "";
+ join "", map {
+ $_, $hash{$_}
+ }sort keys %hash
} @ARGV;
diff --git a/challenge-307/wlmb/perl/ch-2a.pl b/challenge-307/wlmb/perl/ch-2a.pl
new file mode 100755
index 0000000000..ef3f6d4b0e
--- /dev/null
+++ b/challenge-307/wlmb/perl/ch-2a.pl
@@ -0,0 +1,21 @@
+#!/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 among the words Wi.
+ FIN
+my $last;
+my $count=0;
+(!defined $last || $_ ne $last)&&++$count, $last = $_
+ for map {
+ my %hash;
+ $hash{lc $_}++ for split "";
+ join "", map {
+ $_, $hash{$_}
+ }sort keys %hash
+ } @ARGV;
+say "@ARGV -> $count";