diff options
| -rw-r--r-- | challenge-205/wlmb/blog.txt | 2 | ||||
| -rwxr-xr-x | challenge-205/wlmb/perl/ch-1.pl | 14 | ||||
| -rwxr-xr-x | challenge-205/wlmb/perl/ch-2.pl | 13 |
3 files changed, 29 insertions, 0 deletions
diff --git a/challenge-205/wlmb/blog.txt b/challenge-205/wlmb/blog.txt new file mode 100644 index 0000000000..3093a2ced6 --- /dev/null +++ b/challenge-205/wlmb/blog.txt @@ -0,0 +1,2 @@ +https://wlmb.github.io/2023/02/20/PWC205/ + diff --git a/challenge-205/wlmb/perl/ch-1.pl b/challenge-205/wlmb/perl/ch-1.pl new file mode 100755 index 0000000000..5ca49bfbd8 --- /dev/null +++ b/challenge-205/wlmb/perl/ch-1.pl @@ -0,0 +1,14 @@ +#!/usr/bin/env perl +# Perl weekly challenge 205 +# Task 1: Third Highest +# +# See https://wlmb.github.io/2023/02/20/PWC205/#task-1-third-highest +use v5.36; +use List::Util qw(uniqint); +die <<~"FIN" unless @ARGV; + Usage: $0 N1 [N2...] + to find the third highest number from the list N1 N2... + FIN +my @list=(sort {$b<=>$a} uniqint @ARGV); # filter out repetitions and sort descending +push @list, ($list[0]) x 2; # Add two copies of the maximum at the end of the list +say join " ", @ARGV, "->", $list[2]; diff --git a/challenge-205/wlmb/perl/ch-2.pl b/challenge-205/wlmb/perl/ch-2.pl new file mode 100755 index 0000000000..58665e6e2e --- /dev/null +++ b/challenge-205/wlmb/perl/ch-2.pl @@ -0,0 +1,13 @@ +#!/usr/bin/env perl +# Perl weekly challenge 205 +# Task 2: Maximum XOR +# +# See https://wlmb.github.io/2023/02/20/PWC205/#task-2-maximum-xor +use v5.36; +use Algorithm::Combinatorics qw(combinations); +use List::Util qw(max); +die <<~"FIN" unless @ARGV >= 2; + Usage: $0 N1 N2 [N3...] + to find the maximum xor of pairs from the list N1 N2 N3... + FIN +say join " ", @ARGV, "->", max map {$_->[0] ^ $_->[1]} combinations([@ARGV],2); |
