diff options
| author | Mohammad Sajid Anwar <Mohammad.Anwar@yahoo.com> | 2024-01-16 18:31:10 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-16 18:31:10 +0000 |
| commit | 47aa688bbc8f5a56d68e0d3576a7c2827ca79f51 (patch) | |
| tree | 6588d207d910ffc617420f774a816d57ae089b63 | |
| parent | 6d56856c531a19b06a2ec067c6d0f21a4303a789 (diff) | |
| parent | 76a57e5d996ef75edcaa011991818b5d2665e506 (diff) | |
| download | perlweeklychallenge-club-47aa688bbc8f5a56d68e0d3576a7c2827ca79f51.tar.gz perlweeklychallenge-club-47aa688bbc8f5a56d68e0d3576a7c2827ca79f51.tar.bz2 perlweeklychallenge-club-47aa688bbc8f5a56d68e0d3576a7c2827ca79f51.zip | |
Merge pull request #9409 from wlmb/challenges
Solve PWC252
| -rw-r--r-- | challenge-252/wlmb/blog.txt | 1 | ||||
| -rwxr-xr-x | challenge-252/wlmb/perl/ch-1.pl | 12 | ||||
| -rwxr-xr-x | challenge-252/wlmb/perl/ch-2.pl | 14 |
3 files changed, 27 insertions, 0 deletions
diff --git a/challenge-252/wlmb/blog.txt b/challenge-252/wlmb/blog.txt new file mode 100644 index 0000000000..2490bf4e93 --- /dev/null +++ b/challenge-252/wlmb/blog.txt @@ -0,0 +1 @@ +https://wlmb.github.io/2024/01/15/PWC252/ diff --git a/challenge-252/wlmb/perl/ch-1.pl b/challenge-252/wlmb/perl/ch-1.pl new file mode 100755 index 0000000000..e42ac0e2ff --- /dev/null +++ b/challenge-252/wlmb/perl/ch-1.pl @@ -0,0 +1,12 @@ +#!/usr/bin/env perl +# Perl weekly challenge 252 +# Task 1: Special Numbers +# +# See https://wlmb.github.io/2024/01/15/PWC252/#task-1-special-numbers +use v5.36; +use List::Util qw(sum0); +die <<~"FIN" unless @ARGV; + Usage: $0 N1 [N2...] + to sum the squares of the special elements of N1 N2... + FIN +say "@ARGV -> ", sum0 map {$ARGV[$_-1]**2} grep {@ARGV%$_==0} 1..@ARGV; diff --git a/challenge-252/wlmb/perl/ch-2.pl b/challenge-252/wlmb/perl/ch-2.pl new file mode 100755 index 0000000000..927509eb6c --- /dev/null +++ b/challenge-252/wlmb/perl/ch-2.pl @@ -0,0 +1,14 @@ +#!/usr/bin/env perl +# Perl weekly challenge 252 +# Task 2: Unique Sum Zero +# +# See https://wlmb.github.io/2024/01/15/PWC252/#task-2-unique-sum-zero +use v5.36; +die <<~"FIN" unless @ARGV; + Usage: $0 N1 [N2...] + to obtain arrays of N_j numbers that add up to zero. + FIN +for(@ARGV){ + warn("Input must be greater than one"), next unless $_>=1; + say "$_ -> [", join(" ", -$_/2..-1, $_%2?(0):(), 1..$_/2), "]"; +} |
