aboutsummaryrefslogtreecommitdiff
path: root/challenge-324
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <Mohammad.Anwar@yahoo.com>2025-06-06 23:26:14 +0100
committerGitHub <noreply@github.com>2025-06-06 23:26:14 +0100
commitab838c841ffdff146d5a0c7d25d375bb68fccc21 (patch)
tree6eee8996b77411e2a4c70f303aa6290601cbea76 /challenge-324
parente400c589e0601c7d1c643e7c83f3a13eb39336c7 (diff)
parentcb89d632f5fdb4209af12bf8f65566abc2f6072e (diff)
downloadperlweeklychallenge-club-ab838c841ffdff146d5a0c7d25d375bb68fccc21.tar.gz
perlweeklychallenge-club-ab838c841ffdff146d5a0c7d25d375bb68fccc21.tar.bz2
perlweeklychallenge-club-ab838c841ffdff146d5a0c7d25d375bb68fccc21.zip
Merge pull request #12134 from ysth/challenge-324-ysth
challenge 324 idiomatic perl solutions by ysth
Diffstat (limited to 'challenge-324')
-rw-r--r--challenge-324/ysth/blog.txt1
-rw-r--r--challenge-324/ysth/perl/ch-1.pl12
-rw-r--r--challenge-324/ysth/perl/ch-2.pl7
3 files changed, 20 insertions, 0 deletions
diff --git a/challenge-324/ysth/blog.txt b/challenge-324/ysth/blog.txt
new file mode 100644
index 0000000000..231462af66
--- /dev/null
+++ b/challenge-324/ysth/blog.txt
@@ -0,0 +1 @@
+https://blog.ysth.info/idiomatic-perl-solutions-to-the-weekly-challenge-324/
diff --git a/challenge-324/ysth/perl/ch-1.pl b/challenge-324/ysth/perl/ch-1.pl
new file mode 100644
index 0000000000..c651d332c0
--- /dev/null
+++ b/challenge-324/ysth/perl/ch-1.pl
@@ -0,0 +1,12 @@
+use 5.036;
+
+@ARGV = qw(2 2 1 2 3 4) unless @ARGV;
+my ($r, $c, @ints) = map int, @ARGV;
+unless ($r >= 0 && $c >= 0 && @ints == $r * $c) {
+ die "expected count of rows, count of columns, and list of that many integers\n";
+}
+
+my @out = map [splice @ints, 0, $c], 1..$r;
+
+use Data::Dumper;
+say Data::Dumper->new([$_])->Terse(1)->Indent(0)->Dump for @out;
diff --git a/challenge-324/ysth/perl/ch-2.pl b/challenge-324/ysth/perl/ch-2.pl
new file mode 100644
index 0000000000..3e5b873305
--- /dev/null
+++ b/challenge-324/ysth/perl/ch-2.pl
@@ -0,0 +1,7 @@
+use 5.036;
+use List::Util 'sum';
+
+my @ints = grep !/\D/a, @ARGV;
+die "expected list of integers\n" if @ints != @ARGV;
+
+say sum map eval, glob 0 . join '', map "{^$_,}", @ints;