diff options
| author | Luis Mochan <mochan@fis.unam.mx> | 2024-07-29 14:05:28 -0600 |
|---|---|---|
| committer | Luis Mochan <mochan@fis.unam.mx> | 2024-07-29 14:05:28 -0600 |
| commit | 9717ec8d1d5070bcac07a4d10c238e2d56fe7671 (patch) | |
| tree | fa499278a47a3d5f70d27f7ac3b3b98171e88d1a | |
| parent | 31e26b8bdcbe90165bffae2a4eeb3d07152e176e (diff) | |
| download | perlweeklychallenge-club-9717ec8d1d5070bcac07a4d10c238e2d56fe7671.tar.gz perlweeklychallenge-club-9717ec8d1d5070bcac07a4d10c238e2d56fe7671.tar.bz2 perlweeklychallenge-club-9717ec8d1d5070bcac07a4d10c238e2d56fe7671.zip | |
Solve PWC280
| -rw-r--r-- | challenge-280/wlmb/blog.txt | 1 | ||||
| -rwxr-xr-x | challenge-280/wlmb/perl/ch-1.pl | 18 | ||||
| -rwxr-xr-x | challenge-280/wlmb/perl/ch-2.pl | 16 |
3 files changed, 35 insertions, 0 deletions
diff --git a/challenge-280/wlmb/blog.txt b/challenge-280/wlmb/blog.txt new file mode 100644 index 0000000000..b63b336747 --- /dev/null +++ b/challenge-280/wlmb/blog.txt @@ -0,0 +1 @@ +https://wlmb.github.io/2024/07/29/PWC280/ diff --git a/challenge-280/wlmb/perl/ch-1.pl b/challenge-280/wlmb/perl/ch-1.pl new file mode 100755 index 0000000000..c63ce01f0c --- /dev/null +++ b/challenge-280/wlmb/perl/ch-1.pl @@ -0,0 +1,18 @@ +#!/usr/bin/env perl +# Perl weekly challenge 280 +# Task 1: Twice Appearance +# +# See https://wlmb.github.io/2024/07/29/PWC280/#task-1-twice-appearance +use v5.36; +die <<~"FIN" unless @ARGV; + Usage: $0 S1 S2... + to print the first duplicated letter in the strings S1 S2... + FIN +for(@ARGV){ + my %count; + warn("Expected lower case letters only: $_"), next unless /^[a-z]*$/; + print "$_ -> "; + for(split ""){ + say($_),last if ++$count{$_}==2; + } +} diff --git a/challenge-280/wlmb/perl/ch-2.pl b/challenge-280/wlmb/perl/ch-2.pl new file mode 100755 index 0000000000..90d01ef22f --- /dev/null +++ b/challenge-280/wlmb/perl/ch-2.pl @@ -0,0 +1,16 @@ +#!/usr/bin/env perl +# Perl weekly challenge 280 +# Task 2: Count Asterisks +# +# See https://wlmb.github.io/2024/07/29/PWC280/#task-2-count-asterisks +use v5.36; +die <<~"FIN" unless @ARGV; + Usage: $0 S1 S2... + to count the asterisks in the strings S1 S2... that are not within + pairs of vertical bars. + FIN +for(@ARGV){ + print "$_ -> "; + s/\|.*?\|//g; + say tr/*// +} |
