Fix. Return from isSafe, we want to stop iterating when final result is clear.

This commit is contained in:
Sven Weidauer 2024-12-03 18:41:45 +01:00
parent f6425f1d56
commit 8f577f0c64

View file

@ -28,6 +28,6 @@ private fun isSafe(report: List<Int>): Boolean {
return report.fold(State()) { state, next -> return report.fold(State()) { state, next ->
state.update(next) state.update(next)
.also { if (!it.safe) return@fold it } .also { if (!it.safe) return@isSafe false }
}.safe }.safe
} }