diff options
| author | Mohammad Sajid Anwar <Mohammad.Anwar@yahoo.com> | 2025-02-03 11:14:55 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-03 11:14:55 +0000 |
| commit | c470a901e92ea7ce7fd48f4bb3bdb2cde9132b45 (patch) | |
| tree | 62ee2adba639461ff0df5b17d18341d91f57199f | |
| parent | ff5d17a7d3a6a391b7c9275c53273b627ce4bd9f (diff) | |
| parent | ee4fd04a9f90a1c574f49f4eb757fc565b68f935 (diff) | |
| download | perlweeklychallenge-club-c470a901e92ea7ce7fd48f4bb3bdb2cde9132b45.tar.gz perlweeklychallenge-club-c470a901e92ea7ce7fd48f4bb3bdb2cde9132b45.tar.bz2 perlweeklychallenge-club-c470a901e92ea7ce7fd48f4bb3bdb2cde9132b45.zip | |
Merge pull request #11520 from wlmb/challenges
Solve PWC307
| -rw-r--r-- | challenge-307/wlmb/blog.txt | 1 | ||||
| -rwxr-xr-x | challenge-307/wlmb/perl/ch-1.pl | 14 | ||||
| -rwxr-xr-x | challenge-307/wlmb/perl/ch-2.pl | 20 |
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; |
