diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2022-10-03 20:01:40 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-03 20:01:40 +0100 |
| commit | cef3f43eac8266dca1249b29307c9481e41abe35 (patch) | |
| tree | b429a4b35d79d3fe29c2553ce60a064b01952464 | |
| parent | b4e39f8ae34ecbe23d2b041497c81c895345d042 (diff) | |
| parent | 2c6b3d0227d78f7d06a9037bfc1ad7e992cc86c2 (diff) | |
| download | perlweeklychallenge-club-cef3f43eac8266dca1249b29307c9481e41abe35.tar.gz perlweeklychallenge-club-cef3f43eac8266dca1249b29307c9481e41abe35.tar.bz2 perlweeklychallenge-club-cef3f43eac8266dca1249b29307c9481e41abe35.zip | |
Merge pull request #6841 from wlmb/challenges
Solve PWC185
| -rw-r--r-- | challenge-185/wlmb/blog.txt | 1 | ||||
| -rwxr-xr-x | challenge-185/wlmb/perl/ch-1.pl | 21 | ||||
| -rwxr-xr-x | challenge-185/wlmb/perl/ch-2.pl | 10 |
3 files changed, 32 insertions, 0 deletions
diff --git a/challenge-185/wlmb/blog.txt b/challenge-185/wlmb/blog.txt new file mode 100644 index 0000000000..be83de99cf --- /dev/null +++ b/challenge-185/wlmb/blog.txt @@ -0,0 +1 @@ +https://wlmb.github.io/2022/10/03/PWC185/ diff --git a/challenge-185/wlmb/perl/ch-1.pl b/challenge-185/wlmb/perl/ch-1.pl new file mode 100755 index 0000000000..b8431d843c --- /dev/null +++ b/challenge-185/wlmb/perl/ch-1.pl @@ -0,0 +1,21 @@ +#!/usr/bin/env perl +# Perl weekly challenge 185 +# Task 1: MAC Address +# +# See https://wlmb.github.io/2022/10/03/PWC185/#task-1-mac-address +use v5.36; +use List::Util qw(all pairs); +use experimental "try"; +die "Usage: $0 S1 [S2...]\nto convert strings Sn from hhhh.hhhh.hhhh to hh:hh:hh:hh:hh:hh" +unless @ARGV; +for (@ARGV) { + try { + my @quads=split /\./; + die "Expected 3 parts" unless @quads==3; + die "Expected 4-hex-digit parts" unless all {m/[0-9a-f]{4}/} @quads; + say "$_ -> ", join ":", map {join "", @$_} pairs map {split ""} @quads; + } + catch ($m) { + say "Failed for $_: $m"; + } +} diff --git a/challenge-185/wlmb/perl/ch-2.pl b/challenge-185/wlmb/perl/ch-2.pl new file mode 100755 index 0000000000..8159184eaa --- /dev/null +++ b/challenge-185/wlmb/perl/ch-2.pl @@ -0,0 +1,10 @@ +#!/usr/bin/env perl +# Perl weekly challenge 185 +# Task 2: Mask Code +# +# See https://wlmb.github.io/2022/10/03/PWC185/#task-2-mask-code +use v5.36; +for(@ARGV){ + my $n=0; + say "$_ -> ", join "", map {$n<4 && ($n+=s/[A-Za-z0-9]/x/); $_} split "" +} |
