aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <Mohammad.Anwar@yahoo.com>2024-03-18 16:53:07 +0000
committerGitHub <noreply@github.com>2024-03-18 16:53:07 +0000
commite898c4a2e23971a7d2f46b6e992e2eec563edbfe (patch)
tree1c18efc324b0581b656487aa8aec9bf0fb5d048a
parent2cce5fa06bfe9859e189f820541be11d133eb31f (diff)
parent1e9f31b6fcbe385e10c3cde2d47d41d453ec5c68 (diff)
downloadperlweeklychallenge-club-e898c4a2e23971a7d2f46b6e992e2eec563edbfe.tar.gz
perlweeklychallenge-club-e898c4a2e23971a7d2f46b6e992e2eec563edbfe.tar.bz2
perlweeklychallenge-club-e898c4a2e23971a7d2f46b6e992e2eec563edbfe.zip
Merge pull request #9770 from wlmb/challenges
Solve PWC261
-rw-r--r--challenge-261/wlmb/blog.txt1
-rwxr-xr-xchallenge-261/wlmb/perl/ch-1.pl13
-rwxr-xr-xchallenge-261/wlmb/perl/ch-2.pl15
3 files changed, 29 insertions, 0 deletions
diff --git a/challenge-261/wlmb/blog.txt b/challenge-261/wlmb/blog.txt
new file mode 100644
index 0000000000..caa8f9c76e
--- /dev/null
+++ b/challenge-261/wlmb/blog.txt
@@ -0,0 +1 @@
+https://wlmb.github.io/2024/03/18/PWC261/
diff --git a/challenge-261/wlmb/perl/ch-1.pl b/challenge-261/wlmb/perl/ch-1.pl
new file mode 100755
index 0000000000..be54582864
--- /dev/null
+++ b/challenge-261/wlmb/perl/ch-1.pl
@@ -0,0 +1,13 @@
+#!/usr/bin/env perl
+# Perl weekly challenge 261
+# Task 1: Element Digit Sum
+#
+# See https://wlmb.github.io/2024/03/18/PWC261/#task-1-element-digit-sum
+use v5.36;
+use List::Util qw(sum0);
+die <<~"FIN" unless @ARGV;
+ usage: $0 N1 [N2...]
+ to find the diference between the sum of the numbers N1+N2+...
+ and the sum of their digits
+ FIN
+say "@ARGV -> ", sum0 map {$_-sum0 split""} @ARGV;
diff --git a/challenge-261/wlmb/perl/ch-2.pl b/challenge-261/wlmb/perl/ch-2.pl
new file mode 100755
index 0000000000..52d50e3b1e
--- /dev/null
+++ b/challenge-261/wlmb/perl/ch-2.pl
@@ -0,0 +1,15 @@
+#!/usr/bin/env perl
+# Perl weekly challenge 261
+# Task 2: Multiply by Two
+#
+# See https://wlmb.github.io/2024/03/18/PWC261/#task-2-multiply-by-two
+use v5.36;
+use List::Util qw(first);
+die <<~"FIN" unless @ARGV >= 2;
+ Usage: $0 S N1 [N2...]
+ to find the smallest number S*2^n that is not in the list N1 N2...
+ FIN
+my ($start, @ints)=@ARGV;
+print "Start=$start, ints=@ints -> ";
+$start *= 2 while defined first {$_==$start} @ints;
+say $start;