From 6b3888f67ac29397db7ff4c2d42eb1bbf196b687 Mon Sep 17 00:00:00 2001 From: Abigail Date: Wed, 4 Nov 2020 19:49:16 +0100 Subject: Slight optimization. --- challenge-085/abigail/perl/ch-1.pl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/challenge-085/abigail/perl/ch-1.pl b/challenge-085/abigail/perl/ch-1.pl index 3e32fc36a3..7934e9cb89 100644 --- a/challenge-085/abigail/perl/ch-1.pl +++ b/challenge-085/abigail/perl/ch-1.pl @@ -60,6 +60,11 @@ LINE: while (<>) { # Iterate over all pairs # for (my $i = 0; $i < @$array; $i ++) { + # + # If 3 * $$array [$i] >= $MAX, we cannot have any solutions, + # as $$array [$j] >= $$array [$i] for $j > $i. + # + last if 3 * $$array [$i] >= $MAX; for (my $j = $i + 1; $j < @$array; $j ++) { # # If the sum of the first number and twice the second -- cgit