diff options
| -rw-r--r-- | challenge-262/wlmb/blog.txt | 1 | ||||
| -rwxr-xr-x | challenge-262/wlmb/perl/ch-1.pl | 14 | ||||
| -rwxr-xr-x | challenge-262/wlmb/perl/ch-2.pl | 18 |
3 files changed, 33 insertions, 0 deletions
diff --git a/challenge-262/wlmb/blog.txt b/challenge-262/wlmb/blog.txt new file mode 100644 index 0000000000..caf5ca115d --- /dev/null +++ b/challenge-262/wlmb/blog.txt @@ -0,0 +1 @@ +https://wlmb.github.io/2024/03/24/PWC262/ diff --git a/challenge-262/wlmb/perl/ch-1.pl b/challenge-262/wlmb/perl/ch-1.pl new file mode 100755 index 0000000000..3f59a91187 --- /dev/null +++ b/challenge-262/wlmb/perl/ch-1.pl @@ -0,0 +1,14 @@ +#!/usr/bin/env perl +# Perl weekly challenge 262 +# Task 1: Max Positive Negative +# +# See https://wlmb.github.io/2024/03/24/PWC262/#task-1-max-positive-negative +use v5.36; +use List::Util qw(max); +die <<~"FIN" unless @ARGV; + Usage: $0 N1 [N2...] + to find the maximum number of equally signed numbers N_i + FIN +my @count=(0,0); +$count[$_>=0//0]++ for @ARGV; +say "@ARGV -> ", max @count; diff --git a/challenge-262/wlmb/perl/ch-2.pl b/challenge-262/wlmb/perl/ch-2.pl new file mode 100755 index 0000000000..90edbfe082 --- /dev/null +++ b/challenge-262/wlmb/perl/ch-2.pl @@ -0,0 +1,18 @@ +#!/usr/bin/env perl +# Perl weekly challenge 262 +# Task 2: Count Equal Divisible +# +# See https://wlmb.github.io/2024/03/24/PWC262/#task-2-count-equal-divisible +use v5.36; +die <<~"FIN" unless @ARGV>=2; + Usage: $0 K N1 [N2...] + to count pairs N_i==N_j where K divides i*j + FIN +my ($k,@ints)=@ARGV; +my $count=0; +for my $i(0..@ints-2){ + for ($i+1..@ints-1){ + ++$count if $ints[$i]==$ints[$_] && ($i*$_)%$k==0; + } +} +say "k=$k, ints=@ints -> $count"; |
