diff options
| -rw-r--r-- | challenge-250/steve-g-lynn/blog.txt | 1 | ||||
| -rwxr-xr-x | challenge-250/steve-g-lynn/perl/ch-1.pl | 13 | ||||
| -rwxr-xr-x | challenge-250/steve-g-lynn/perl/ch-2.pl | 15 |
3 files changed, 29 insertions, 0 deletions
diff --git a/challenge-250/steve-g-lynn/blog.txt b/challenge-250/steve-g-lynn/blog.txt new file mode 100644 index 0000000000..99346ade71 --- /dev/null +++ b/challenge-250/steve-g-lynn/blog.txt @@ -0,0 +1 @@ +https://thiujiac.blogspot.com/2023/12/pwc-250.html diff --git a/challenge-250/steve-g-lynn/perl/ch-1.pl b/challenge-250/steve-g-lynn/perl/ch-1.pl new file mode 100755 index 0000000000..4ec66d9008 --- /dev/null +++ b/challenge-250/steve-g-lynn/perl/ch-1.pl @@ -0,0 +1,13 @@ +#!/usr/bin/env -S perl -wl + +my $smallest_index = sub { + my $retval= + (sort {$a<=>$b} + (grep {($_ % 10) == ($_[$_])} (0 .. $#_)) + )[0]; + defined($retval) ? $retval : -1; +}; + +print &$smallest_index(0,1,2); #0 +print &$smallest_index(4,3,2,1); #2 +print &$smallest_index(1,2,3,4,5,6,7,8,9,0); #-1 diff --git a/challenge-250/steve-g-lynn/perl/ch-2.pl b/challenge-250/steve-g-lynn/perl/ch-2.pl new file mode 100755 index 0000000000..c3ac3877e2 --- /dev/null +++ b/challenge-250/steve-g-lynn/perl/ch-2.pl @@ -0,0 +1,15 @@ +#!/usr/bin/env -S perl -wl + +local *alphanumeric_string_value = sub { + local *alphanumeric_string_value = sub { + ($_[0] =~ /^[0-9]+$/) ? + (0+$_[0]) : + length($_[0]); + }; + + (sort {$b<=>$a} + (map {&alphanumeric_string_value($_)} @_)) [0]; +}; + +print &alphanumeric_string_value('perl','2','000','python','r4ku');#6 +print &alphanumeric_string_value('001','1','000','0001');#1 |
