diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2020-05-13 08:24:32 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-13 08:24:32 +0100 |
| commit | 487a05e1c99c52de7555307891a6c72844c1cdcc (patch) | |
| tree | d56589e26f6e6dad2c4c6f4059dfe89ed2a408a7 | |
| parent | e9836f435b61b0b43738fa4efe266cf9a88642e3 (diff) | |
| parent | f2b31fb8b2190f35b35a24c2d4d183c20b91ca24 (diff) | |
| download | perlweeklychallenge-club-487a05e1c99c52de7555307891a6c72844c1cdcc.tar.gz perlweeklychallenge-club-487a05e1c99c52de7555307891a6c72844c1cdcc.tar.bz2 perlweeklychallenge-club-487a05e1c99c52de7555307891a6c72844c1cdcc.zip | |
Merge pull request #1712 from choroba/ech060b
Add blog post by E. Choroba about 060: Excel Column + Find Numbers
| -rw-r--r-- | challenge-060/e-choroba/blog.txt | 1 | ||||
| -rwxr-xr-x | challenge-060/e-choroba/perl/ch-2.pl | 8 |
2 files changed, 8 insertions, 1 deletions
diff --git a/challenge-060/e-choroba/blog.txt b/challenge-060/e-choroba/blog.txt new file mode 100644 index 0000000000..8f5cf5af70 --- /dev/null +++ b/challenge-060/e-choroba/blog.txt @@ -0,0 +1 @@ +http://blogs.perl.org/users/e_choroba/2020/05/perl-weekly-challenge-060-excel-column-and-find-numbers.html diff --git a/challenge-060/e-choroba/perl/ch-2.pl b/challenge-060/e-choroba/perl/ch-2.pl index d469490fd9..0894531600 100755 --- a/challenge-060/e-choroba/perl/ch-2.pl +++ b/challenge-060/e-choroba/perl/ch-2.pl @@ -24,7 +24,10 @@ sub extend { sub find { my ($length, $greater, @list) = @_; - return grep $greater > $_, extend($length, \@list, {}); + my @long = grep $length == length $_, @list; + my %long; undef @long{@long} if @long; + return grep $greater > $_, + extend($length, \@list, \%long); } use Test::More; @@ -49,4 +52,7 @@ cmp_deeply [ find(5, 30000, 1, 20, 300) ], bag(11111, 11120, 11201, 11300, 12011, 12020, 13001, 20111, 20120, 20201, 20300); +cmp_deeply [ find(3, 789, 123, 456, 1000) ], + bag(123, 456); + done_testing(); |
