diff options
| author | Mohammad Sajid Anwar <Mohammad.Anwar@yahoo.com> | 2025-06-06 23:26:14 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-06 23:26:14 +0100 |
| commit | ab838c841ffdff146d5a0c7d25d375bb68fccc21 (patch) | |
| tree | 6eee8996b77411e2a4c70f303aa6290601cbea76 /challenge-324 | |
| parent | e400c589e0601c7d1c643e7c83f3a13eb39336c7 (diff) | |
| parent | cb89d632f5fdb4209af12bf8f65566abc2f6072e (diff) | |
| download | perlweeklychallenge-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.txt | 1 | ||||
| -rw-r--r-- | challenge-324/ysth/perl/ch-1.pl | 12 | ||||
| -rw-r--r-- | challenge-324/ysth/perl/ch-2.pl | 7 |
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; |
