aboutsummaryrefslogtreecommitdiff
path: root/challenge-085/abigail
diff options
context:
space:
mode:
authorAbigail <abigail@abigail.be>2020-11-04 19:49:16 +0100
committerAbigail <abigail@abigail.be>2020-11-04 19:49:16 +0100
commit6b3888f67ac29397db7ff4c2d42eb1bbf196b687 (patch)
tree3ad92676c141be464f8dc70f0b02a699a1526172 /challenge-085/abigail
parentef136c2d3c199b6ae7e487b60299a8974a0c4d57 (diff)
downloadperlweeklychallenge-club-6b3888f67ac29397db7ff4c2d42eb1bbf196b687.tar.gz
perlweeklychallenge-club-6b3888f67ac29397db7ff4c2d42eb1bbf196b687.tar.bz2
perlweeklychallenge-club-6b3888f67ac29397db7ff4c2d42eb1bbf196b687.zip
Slight optimization.
Diffstat (limited to 'challenge-085/abigail')
-rw-r--r--challenge-085/abigail/perl/ch-1.pl5
1 files changed, 5 insertions, 0 deletions
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