From bb5cdc566c09047fde7d329f34dfcc919cba0e74 Mon Sep 17 00:00:00 2001 From: Flashk Date: Sat, 7 Dec 2024 09:16:09 +0100 Subject: [PATCH] refactor: add minor optimization improvement to day 7 --- src/main/java/com/adventofcode/flashk/day07/Equation.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/adventofcode/flashk/day07/Equation.java b/src/main/java/com/adventofcode/flashk/day07/Equation.java index cb90f99..bbb3a6c 100644 --- a/src/main/java/com/adventofcode/flashk/day07/Equation.java +++ b/src/main/java/com/adventofcode/flashk/day07/Equation.java @@ -30,6 +30,8 @@ private boolean hasSolution(long partialResult) { if(operators.isEmpty()) { return partialResult == result; + } else if(partialResult > result) { + return false; } Integer currentOperator = operators.poll();