diff options
| author | Lubos Kolouch <lubos@kolouch.net> | 2020-09-28 17:10:25 +0200 |
|---|---|---|
| committer | Lubos Kolouch <lubos@kolouch.net> | 2020-09-28 17:10:25 +0200 |
| commit | 1cacdbb6efed31b4d4bda32d3b548c3ad9205be4 (patch) | |
| tree | 7dcd02faac066c961f40939796c04909f35b707a /challenge-080 | |
| parent | 98b8162b7f4bcda6060dedd8e4adce1e76988fa3 (diff) | |
| download | perlweeklychallenge-club-1cacdbb6efed31b4d4bda32d3b548c3ad9205be4.tar.gz perlweeklychallenge-club-1cacdbb6efed31b4d4bda32d3b548c3ad9205be4.tar.bz2 perlweeklychallenge-club-1cacdbb6efed31b4d4bda32d3b548c3ad9205be4.zip | |
file rename
Diffstat (limited to 'challenge-080')
| -rw-r--r-- | challenge-080/lubos-kolouch/perl/ch-1.pl (renamed from challenge-080/lubos-kolouch/perl/ch_1.pl) | 8 | ||||
| -rw-r--r-- | challenge-080/lubos-kolouch/perl/ch-2.pl (renamed from challenge-080/lubos-kolouch/perl/ch_2.pl) | 0 |
2 files changed, 5 insertions, 3 deletions
diff --git a/challenge-080/lubos-kolouch/perl/ch_1.pl b/challenge-080/lubos-kolouch/perl/ch-1.pl index 8362cfa572..7461ceb1b9 100644 --- a/challenge-080/lubos-kolouch/perl/ch_1.pl +++ b/challenge-080/lubos-kolouch/perl/ch-1.pl @@ -27,13 +27,15 @@ sub get_smallest_missing { # Not lucky, arr_min is 0, so need to iterate # NOTE: the excercise does not say what to do if there is nothing missing - # so let's just return min + 1 and ask on Twitter the author :) + # so let's just return 0 as per Twitter confirmation - while (1) { + for (0..scalar @$arr-2) { $arr_min++; return $arr_min unless grep { $_ == $arr_min } @$arr; } + + return 0; } use Test::More; @@ -41,6 +43,6 @@ use Test::More; is(get_smallest_missing([5, 2, -2, 0]), 1); is(get_smallest_missing([1, 8, -1]), 2); is(get_smallest_missing([2, 0, -1]), 1); -is(get_smallest_missing([2, 0, 1]), 3); +is(get_smallest_missing([2, 0, 1]), 0); done_testing; diff --git a/challenge-080/lubos-kolouch/perl/ch_2.pl b/challenge-080/lubos-kolouch/perl/ch-2.pl index 3c01308c37..3c01308c37 100644 --- a/challenge-080/lubos-kolouch/perl/ch_2.pl +++ b/challenge-080/lubos-kolouch/perl/ch-2.pl |
