diff options
| -rw-r--r-- | challenge-260/wlmb/blog.txt | 1 | ||||
| -rwxr-xr-x | challenge-260/wlmb/perl/ch-1.pl | 16 | ||||
| -rwxr-xr-x | challenge-260/wlmb/perl/ch-2.pl | 20 |
3 files changed, 37 insertions, 0 deletions
diff --git a/challenge-260/wlmb/blog.txt b/challenge-260/wlmb/blog.txt new file mode 100644 index 0000000000..811d5def4a --- /dev/null +++ b/challenge-260/wlmb/blog.txt @@ -0,0 +1 @@ +https://wlmb.github.io/2024/03/10/PWC260/ diff --git a/challenge-260/wlmb/perl/ch-1.pl b/challenge-260/wlmb/perl/ch-1.pl new file mode 100755 index 0000000000..135a9b04d9 --- /dev/null +++ b/challenge-260/wlmb/perl/ch-1.pl @@ -0,0 +1,16 @@ +#!/usr/bin/env perl +# Perl weekly challenge 260 +# Task 1: Unique Occurrences +# +# See https://wlmb.github.io/2024/03/10/PWC260/#task-1-unique-occurrences +use v5.36; +use List::Util qw(uniq); +die <<~"FIN" unless @ARGV; + Usage: $0 N1 [N2...] + to test if the number of ocurrences of each number is unique. + FIN +my %counts; +++$counts{$_} for @ARGV; +my @counts=values %counts; +my $result=@counts==(uniq @counts)||0; +say "@ARGV => $result"; diff --git a/challenge-260/wlmb/perl/ch-2.pl b/challenge-260/wlmb/perl/ch-2.pl new file mode 100755 index 0000000000..c7f9ba1ecc --- /dev/null +++ b/challenge-260/wlmb/perl/ch-2.pl @@ -0,0 +1,20 @@ +#!/usr/bin/env perl +# Perl weekly challenge 260 +# Task 2: Dictionary Rank +# +# See https://wlmb.github.io/2024/03/10/PWC260/#task-2-dictionary-rank +use v5.36; +use Algorithm::Combinatorics qw(permutations); +use List::AllUtils qw(uniq onlyidx); +die <<~"FIN" unless @ARGV; + Usage: $0 W1 [W2...] + to find the dictionary rank of words W1 W2... + FIN +for(@ARGV){ + my @letters=split "", my $word=lc; + say "$_ => ", 1+onlyidx {$_ eq $word} + sort{$a cmp $b} + uniq + map {join "", @$_} + permutations(\@letters); +} |
