diff options
| author | Mohammad Sajid Anwar <Mohammad.Anwar@yahoo.com> | 2024-01-01 14:06:13 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-01 14:06:13 +0000 |
| commit | 9ab0a89f5ebbe4389a1c29e5d65cd0c4f8a96de0 (patch) | |
| tree | 134f6cd37ca38b934328c0f4e04347a4b6c424fd | |
| parent | 0d024c3d22847623af662c4219d5b06bd5c9b353 (diff) | |
| parent | 81e06aa109db256fbead8f88b6bc76c22db82320 (diff) | |
| download | perlweeklychallenge-club-9ab0a89f5ebbe4389a1c29e5d65cd0c4f8a96de0.tar.gz perlweeklychallenge-club-9ab0a89f5ebbe4389a1c29e5d65cd0c4f8a96de0.tar.bz2 perlweeklychallenge-club-9ab0a89f5ebbe4389a1c29e5d65cd0c4f8a96de0.zip | |
Merge pull request #9325 from steve-g-lynn/branch-for-challenge-250
PWC 250
| -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 |
