aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <Mohammad.Anwar@yahoo.com>2024-01-08 18:54:26 +0000
committerGitHub <noreply@github.com>2024-01-08 18:54:26 +0000
commit0a59813578c2df464a5978a5c3fb4f1919e2accc (patch)
tree069d040bd04d9b34b22733c4b264eb1929b96ea8
parent9e9957260457139be26195c7c0bd5a6bebfbcde5 (diff)
parent598422b9745ea871f161f2dcbfd883380ab706b1 (diff)
downloadperlweeklychallenge-club-0a59813578c2df464a5978a5c3fb4f1919e2accc.tar.gz
perlweeklychallenge-club-0a59813578c2df464a5978a5c3fb4f1919e2accc.tar.bz2
perlweeklychallenge-club-0a59813578c2df464a5978a5c3fb4f1919e2accc.zip
Merge pull request #9373 from wlmb/challenges
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;
+}