aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xchallenge-250/e-choroba/perl/ch-1.pl17
-rwxr-xr-xchallenge-250/e-choroba/perl/ch-2.pl17
2 files changed, 34 insertions, 0 deletions
diff --git a/challenge-250/e-choroba/perl/ch-1.pl b/challenge-250/e-choroba/perl/ch-1.pl
new file mode 100755
index 0000000000..4f6a866e4b
--- /dev/null
+++ b/challenge-250/e-choroba/perl/ch-1.pl
@@ -0,0 +1,17 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+use experimental qw( signatures );
+
+use List::Util qw{ first };
+
+sub smallest_index(@ints) {
+ my $i = first { $_ % 10 == $ints[$_] } 0 .. $#ints;
+ return $i // -1
+}
+
+use Test::More tests => 3;
+
+is smallest_index(0, 1, 2), 0, 'Example 1';
+is smallest_index(4, 3, 2, 1), 2, 'Example 2';
+is smallest_index(1, 2, 3, 4, 5, 6, 7, 8, 9, 0), -1, 'Example 3';
diff --git a/challenge-250/e-choroba/perl/ch-2.pl b/challenge-250/e-choroba/perl/ch-2.pl
new file mode 100755
index 0000000000..728623fa12
--- /dev/null
+++ b/challenge-250/e-choroba/perl/ch-2.pl
@@ -0,0 +1,17 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+use experimental qw( signatures );
+
+use List::Util qw{ max };
+
+sub alphanumeric_string_value(@alphanumstr) {
+ return max(map /^[0-9]+$/ ? 0 + $_ : length, @alphanumstr)
+}
+
+use Test::More tests => 2;
+
+is alphanumeric_string_value('perl', '2', '000', 'python', 'r4ku'), 6,
+ 'Example 1';
+is alphanumeric_string_value('001', '1', '000', '0001'), 1,
+ 'Example 2';