diff options
| author | Stephen Lynn <bizlsg@localhost.localdomain> | 2024-01-01 13:11:12 +0800 |
|---|---|---|
| committer | Stephen Lynn <bizlsg@localhost.localdomain> | 2024-01-01 13:11:12 +0800 |
| commit | 81e06aa109db256fbead8f88b6bc76c22db82320 (patch) | |
| tree | ec410f3cbb5a7dff65ef965f818ecc6c00ad569d | |
| parent | 558be93cbb41f6a2459bdb7194e2d9348c87ea38 (diff) | |
| download | perlweeklychallenge-club-81e06aa109db256fbead8f88b6bc76c22db82320.tar.gz perlweeklychallenge-club-81e06aa109db256fbead8f88b6bc76c22db82320.tar.bz2 perlweeklychallenge-club-81e06aa109db256fbead8f88b6bc76c22db82320.zip | |
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 |
