We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 45a5ef6 commit 0e4fe48Copy full SHA for 0e4fe48
src/main/scala/eu/sim642/adventofcode2024/Day18.scala
@@ -64,14 +64,12 @@ object Day18 {
64
65
@tailrec
66
def helper(after: Int, path: Set[Pos]): Int = {
67
- if (path(bytes(after))) {
68
- exitPath(bytes, max, after +1) match {
69
- caseSome(newPath) => helper(after +1, newPath.toSet)
70
- case None => after +1
71
- }
+ valnewAfter=bytes.indexWhere(path, after)+1
+ assert(newAfter >=1) // indexWhere didn't return -1
+ exitPath(bytes, max, newAfter) match {
+ case Some(newPath) => helper(newAfter, newPath.toSet)
+ caseNone=> newAfter
72
}
73
- else
74
- helper(after + 1, path)
75
76
77
val blockingAfter = helper(0, exitPath(bytes, max, 0).get.toSet)
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments