aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-044/e-choroba/blog.txt1
-rwxr-xr-xchallenge-044/e-choroba/perl/ch-1.pl3
-rwxr-xr-xchallenge-044/e-choroba/perl/ch-2.pl4
3 files changed, 4 insertions, 4 deletions
diff --git a/challenge-044/e-choroba/blog.txt b/challenge-044/e-choroba/blog.txt
new file mode 100644
index 0000000000..e261bf0ba3
--- /dev/null
+++ b/challenge-044/e-choroba/blog.txt
@@ -0,0 +1 @@
+http://blogs.perl.org/users/e_choroba/2020/01/perl-weekly-challenge-044-one-hundred-two-hundred.html
diff --git a/challenge-044/e-choroba/perl/ch-1.pl b/challenge-044/e-choroba/perl/ch-1.pl
index a57b89a121..13e45ea8cd 100755
--- a/challenge-044/e-choroba/perl/ch-1.pl
+++ b/challenge-044/e-choroba/perl/ch-1.pl
@@ -39,9 +39,10 @@ sub increment {
}
my @mask = (NOTHING) x (@digits - 1);
-while (grep $_ != MINUS, @mask) {
+while (1) {
my $expression = apply(\@mask);
say $expression if 100 == evaluate($expression);
+ last unless grep $_ != MINUS, @mask;
increment(\@mask);
}
diff --git a/challenge-044/e-choroba/perl/ch-2.pl b/challenge-044/e-choroba/perl/ch-2.pl
index 6e63e62be3..5bf43cacf3 100755
--- a/challenge-044/e-choroba/perl/ch-2.pl
+++ b/challenge-044/e-choroba/perl/ch-2.pl
@@ -5,12 +5,10 @@ use feature qw{ say };
my %possibilities = (1 => []);
while (! exists $possibilities{200}) {
- my %next;
for my $p (keys %possibilities) {
- $next{ $_ } = [ @{ $possibilities{$p} }, $p ]
+ $possibilities{ $_ } ||= [ @{ $possibilities{$p} }, $p ]
for $p + 1, $p * 2;
}
- %possibilities = %next;
}
my @moves = @{ $possibilities{200} };