diff options
| -rw-r--r-- | challenge-254/wlmb/blog.txt | 1 | ||||
| -rwxr-xr-x | challenge-254/wlmb/perl/ch-1.pl | 15 | ||||
| -rwxr-xr-x | challenge-254/wlmb/perl/ch-2.pl | 17 |
3 files changed, 33 insertions, 0 deletions
diff --git a/challenge-254/wlmb/blog.txt b/challenge-254/wlmb/blog.txt new file mode 100644 index 0000000000..a31d35a7ab --- /dev/null +++ b/challenge-254/wlmb/blog.txt @@ -0,0 +1 @@ +https://wlmb.github.io/2024/01/29/PWC254/ diff --git a/challenge-254/wlmb/perl/ch-1.pl b/challenge-254/wlmb/perl/ch-1.pl new file mode 100755 index 0000000000..3cca2702aa --- /dev/null +++ b/challenge-254/wlmb/perl/ch-1.pl @@ -0,0 +1,15 @@ +#!/usr/bin/env perl +# Perl weekly challenge 254 +# Task 1: Three Power +# +# See https://wlmb.github.io/2024/01/29/PWC254/#task-1-three-power +use v5.36; +use POSIX qw(lround); +die <<~"FIN" unless @ARGV; + Usage: $0 N1 [N2...] + to check if the integers N1 N2... are cubes + FIN +for(@ARGV){ + warn("$_ not integer"),next unless $_ == lround($_); + say "$_ -> ", abs($_)==lround(abs($_)**(1/3))**3?"True":"False"; +} diff --git a/challenge-254/wlmb/perl/ch-2.pl b/challenge-254/wlmb/perl/ch-2.pl new file mode 100755 index 0000000000..b2095c59e0 --- /dev/null +++ b/challenge-254/wlmb/perl/ch-2.pl @@ -0,0 +1,17 @@ +#!/usr/bin/env perl +# Perl weekly challenge 254 +# Task 2: Reverse Vowels +# +# See https://wlmb.github.io/2024/01/29/PWC254/#task-2-reverse-vowels +use v5.36; +die <<~"FIN" unless @ARGV; + Usage: $0 W1 [W2..] + to reverse the vowels in the words W1 W2... + FIN +for(@ARGV){ + my @all = split "", lc $_; + my @vowel_indices=grep {$all[$_]=~/[aeiou]/} 0..@all-1; + @all[@vowel_indices]=reverse @all[@vowel_indices]; + my $out=ucfirst join "", @all; + say "$_ -> $out"; +} |
