aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuis Mochan <mochan@fis.unam.mx>2024-01-08 09:30:01 -0600
committerLuis Mochan <mochan@fis.unam.mx>2024-01-08 09:30:01 -0600
commit598422b9745ea871f161f2dcbfd883380ab706b1 (patch)
tree761246c7568801cb9db162d63d7fdba9e465dfe8
parent9a485c9bac8e3887b165d67c9aa81d71cdd42f01 (diff)
downloadperlweeklychallenge-club-598422b9745ea871f161f2dcbfd883380ab706b1.tar.gz
perlweeklychallenge-club-598422b9745ea871f161f2dcbfd883380ab706b1.tar.bz2
perlweeklychallenge-club-598422b9745ea871f161f2dcbfd883380ab706b1.zip
SOlve PWC251
-rw-r--r--challenge-251/wlmb/blog.txt1
-rwxr-xr-xchallenge-251/wlmb/perl/ch-1.pl14
-rwxr-xr-xchallenge-251/wlmb/perl/ch-2.pl20
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;
+}