aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xchallenge-254/e-choroba/perl/ch-1.pl20
-rwxr-xr-xchallenge-254/e-choroba/perl/ch-2.pl20
2 files changed, 40 insertions, 0 deletions
diff --git a/challenge-254/e-choroba/perl/ch-1.pl b/challenge-254/e-choroba/perl/ch-1.pl
new file mode 100755
index 0000000000..0920ddf653
--- /dev/null
+++ b/challenge-254/e-choroba/perl/ch-1.pl
@@ -0,0 +1,20 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+use experimental qw( signatures );
+
+sub three_power($n) {
+ for (1, 2) {
+ return if $n % 3;
+ $n /= 3;
+ }
+ return 1
+}
+
+use Test::More tests => 3 + 2;
+
+ok three_power(27), 'Example 1';
+ok three_power(0), 'Example 2';
+ok ! three_power(6), 'Example 3';
+ok three_power(18446703239944862784), 'Large true';
+ok ! three_power(18446744073709551615), 'Large false';
diff --git a/challenge-254/e-choroba/perl/ch-2.pl b/challenge-254/e-choroba/perl/ch-2.pl
new file mode 100755
index 0000000000..11c56a1804
--- /dev/null
+++ b/challenge-254/e-choroba/perl/ch-2.pl
@@ -0,0 +1,20 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+use experimental qw( signatures );
+
+sub reverse_vowels($s) {
+ my @vowels = $s =~ /[aeiou]/gi;
+ $s =~ s{([aeiou])}{
+ my $v = pop @vowels;
+ $1 ge 'a' ? lc $v : uc $v
+ }ige;
+ return $s
+}
+
+use Test::More tests => 4;
+
+is reverse_vowels('Raku'), 'Ruka', 'Example 1';
+is reverse_vowels('Perl'), 'Perl', 'Example 2';
+is reverse_vowels('Julia'), 'Jaliu', 'Example 3';
+is reverse_vowels('Uiua'), 'Auiu', 'Example 4';