diff options
| author | Mohammad Sajid Anwar <Mohammad.Anwar@yahoo.com> | 2024-09-09 09:14:51 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-09 09:14:51 +0100 |
| commit | 1e8d416887fbc05f48dbaa9d780511171e570fb7 (patch) | |
| tree | 9444ecfb7def81777e5d7bfd82fd7d932c679937 | |
| parent | 3de021e2b41ac1e2172d4dfb4b5fcc7987d49676 (diff) | |
| parent | 9cd8d5744483532cef7030180b829b07b4a97c5d (diff) | |
| download | perlweeklychallenge-club-1e8d416887fbc05f48dbaa9d780511171e570fb7.tar.gz perlweeklychallenge-club-1e8d416887fbc05f48dbaa9d780511171e570fb7.tar.bz2 perlweeklychallenge-club-1e8d416887fbc05f48dbaa9d780511171e570fb7.zip | |
Merge pull request #10799 from wlmb/challenges
Solve PWC286
| -rw-r--r-- | challenge-286/wlmb/blog.txt | 1 | ||||
| -rwxr-xr-x | challenge-286/wlmb/perl/ch-1.pl | 8 | ||||
| -rwxr-xr-x | challenge-286/wlmb/perl/ch-2.pl | 22 |
3 files changed, 31 insertions, 0 deletions
diff --git a/challenge-286/wlmb/blog.txt b/challenge-286/wlmb/blog.txt new file mode 100644 index 0000000000..16cf556b09 --- /dev/null +++ b/challenge-286/wlmb/blog.txt @@ -0,0 +1 @@ +https://wlmb.github.io/2024/09/08/PWC286/ diff --git a/challenge-286/wlmb/perl/ch-1.pl b/challenge-286/wlmb/perl/ch-1.pl new file mode 100755 index 0000000000..7ae442676f --- /dev/null +++ b/challenge-286/wlmb/perl/ch-1.pl @@ -0,0 +1,8 @@ +#!/usr/bin/env perl +# Perl weekly challenge 286 +# Task 1: Self Spammer +# +# See https://wlmb.github.io/2024/09/08/PWC286/#task-1-self-spammer +use v5.36; +my @words = qw( @words = qw( ) say $words [ rand( 0+@words ) ] ; ); +say $words [ rand( 0+@words ) ] ; diff --git a/challenge-286/wlmb/perl/ch-2.pl b/challenge-286/wlmb/perl/ch-2.pl new file mode 100755 index 0000000000..08163d0a8a --- /dev/null +++ b/challenge-286/wlmb/perl/ch-2.pl @@ -0,0 +1,22 @@ +#!/usr/bin/env perl +# Perl weekly challenge 286 +# Task 2: Order Game +# +# See https://wlmb.github.io/2024/09/08/PWC286/#task-2-order-game +use v5.36; +use List::Util qw(min max); +use experimental qw(for_list); +die <<~"FIN" unless @ARGV and ((@ARGV&(@ARGV-1))==0); #finite power of 2 + Usage: $0 N1 N2...Nm + where m is a power of two to choose min max of consecutive pairs + and iterate until surviving element is found + FIN +my @next=@ARGV; +while(@next>2){ + my @minmax; + for my($p,$q,$r,$s)(@next){ + push @minmax, min($p,$q),max($r,$s); + } + @next=@minmax; +} +say "@ARGV -> ",min(@next) |
