From b9d62c2835e6ccefe7e2dc511690c444a3d62a6b Mon Sep 17 00:00:00 2001 From: Hubert Van De Walle Date: Fri, 18 Dec 2020 12:30:13 +0100 Subject: [PATCH] Use LinkedList.peekLast() to avoid walking the whole list --- days/src/main/kotlin/Day18.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/days/src/main/kotlin/Day18.kt b/days/src/main/kotlin/Day18.kt index e442793..338e0e6 100644 --- a/days/src/main/kotlin/Day18.kt +++ b/days/src/main/kotlin/Day18.kt @@ -58,7 +58,7 @@ class Day18(@Lines val input: Input>) { operands[i + 1] = result } - return operands.last() + return operands.peekLast() } else { var i = 0