diff options
| -rw-r--r-- | challenge-251/wlmb/blog.txt | 1 | ||||
| -rwxr-xr-x | challenge-251/wlmb/perl/ch-1.pl | 14 | ||||
| -rwxr-xr-x | challenge-251/wlmb/perl/ch-2.pl | 20 |
3 files changed, 35 insertions, 0 deletions
diff --git a/challenge-251/wlmb/blog.txt b/challenge-251/wlmb/blog.txt new file mode 100644 index 0000000000..3c2c1d1653 --- /dev/null +++ b/challenge-251/wlmb/blog.txt @@ -0,0 +1 @@ +https://wlmb.github.io/2024/01/08/PWC251/ diff --git a/challenge-251/wlmb/perl/ch-1.pl b/challenge-251/wlmb/perl/ch-1.pl new file mode 100755 index 0000000000..828c183030 --- /dev/null +++ b/challenge-251/wlmb/perl/ch-1.pl @@ -0,0 +1,14 @@ +#!/usr/bin/env perl +# Perl weekly challenge 251 +# Task 1: Concatenation Value +# +# See https://wlmb.github.io/2024/01/08/PWC251/#task-1-concatenation-value +use v5.36; +die <<~"FIN" unless @ARGV; + Usage: $0 N1 [N2...] + to concatenate and add the numbers N_1 . N_k + N_2 . N_{k-1} +... + FIN +my $tot=0; +my @ints=@ARGV; +$tot += shift(@ints).(pop(@ints)//"") while(@ints); +say "@ARGV -> $tot"; diff --git a/challenge-251/wlmb/perl/ch-2.pl b/challenge-251/wlmb/perl/ch-2.pl new file mode 100755 index 0000000000..d835b0f63a --- /dev/null +++ b/challenge-251/wlmb/perl/ch-2.pl @@ -0,0 +1,20 @@ +#!/usr/bin/env perl +# Perl weekly challenge 251 +# Task 2: Lucky Numbers +# +# See https://wlmb.github.io/2024/01/08/PWC251/#task-2-lucky-numbers +use v5.36; +use PDL; +die <<~"FIN" unless @ARGV; + Usage: $0 A1 [A2...] + to find lucky numbers in the arrays A1, A2... + The format of the arrays should be "[[a00 a01...],[a10 a11...],...]", + to be read by pdl. + FIN +while(@ARGV){ + my $in=pdl(shift); + my $min=$in->minover->dummy(0); + my $max=$in->mv(1,0)->maxover->dummy(1); + my $result=$in->where(($in==$min)&($in==$max)); + say "$in -> ", $result->isempty?-1:$result; +} |
