From 8f577f0c649cfc86cb3025a77e6652163b2c8d69 Mon Sep 17 00:00:00 2001 From: Sven Weidauer Date: Tue, 3 Dec 2024 18:41:45 +0100 Subject: [PATCH] Fix. Return from isSafe, we want to stop iterating when final result is clear. --- 2024/src/main/kotlin/day2.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2024/src/main/kotlin/day2.kt b/2024/src/main/kotlin/day2.kt index ca8bc40..de070a1 100644 --- a/2024/src/main/kotlin/day2.kt +++ b/2024/src/main/kotlin/day2.kt @@ -28,6 +28,6 @@ private fun isSafe(report: List): Boolean { return report.fold(State()) { state, next -> state.update(next) - .also { if (!it.safe) return@fold it } + .also { if (!it.safe) return@isSafe false } }.safe }