aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorE. Choroba <choroba@matfyz.cz>2020-05-13 01:03:52 +0200
committerE. Choroba <choroba@matfyz.cz>2020-05-13 01:03:52 +0200
commitf2b31fb8b2190f35b35a24c2d4d183c20b91ca24 (patch)
tree3731edf026507fae636ac3968e6e0cf778bade1b
parent6d4b1f3e3b9ec173194372bd43386c27bea638ce (diff)
downloadperlweeklychallenge-club-f2b31fb8b2190f35b35a24c2d4d183c20b91ca24.tar.gz
perlweeklychallenge-club-f2b31fb8b2190f35b35a24c2d4d183c20b91ca24.tar.bz2
perlweeklychallenge-club-f2b31fb8b2190f35b35a24c2d4d183c20b91ca24.zip
Add blog post by E. Choroba about 060: Excel Column + Find Numbers
Also, fix the edge case where input numbers of the target length were ignored in "Find Numbers".
-rw-r--r--challenge-060/e-choroba/blog.txt1
-rwxr-xr-xchallenge-060/e-choroba/perl/ch-2.pl8
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();