aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xchallenge-194/perlboy1967/perl/ch-1.pl6
1 files changed, 3 insertions, 3 deletions
diff --git a/challenge-194/perlboy1967/perl/ch-1.pl b/challenge-194/perlboy1967/perl/ch-1.pl
index 8826c9ba6b..3e36138700 100755
--- a/challenge-194/perlboy1967/perl/ch-1.pl
+++ b/challenge-194/perlboy1967/perl/ch-1.pl
@@ -23,13 +23,13 @@ use Test::More;
sub highestDigit ($) {
- state $c = { -1=>-1, 0=>2, 1=>9, 2=>-1, 3=>5, 4=>9 };
+ state $c = { 0=>2, 1=>9, 2=>-1, 3=>5, 4=>9 };
- ($_[0] =~ y/?/?/) != 1 ? -1 : $c->{index($_[0],'?')}
+ (length($_[0]) == 5 && $_[0] =~ y/?/?/) == 1 ? $c->{index($_[0],'?')} // -1 : -1;
}
-my %t = qw(?0:00 2 1?:00 9 10:?2 5 12:1? 9 ??:00 -1 00?00 -1);
+my %t = qw(?0:00 2 1?:00 9 10:?2 5 12:1? 9 ??:00 -1 00?00 -1 00:00? -1 ?00:00 -1);
for (sort keys %t) {
is(highestDigit($_),$t{$_},"highestDigit('$_')");