Skip to content

Commit

Permalink
🎨 .inits instead of .reverse.tails
Browse files Browse the repository at this point in the history
  • Loading branch information
twentylemon committed Dec 18, 2024
1 parent b932673 commit bd3e157
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/scala/org/lemon/advent/year2024/Day18.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ private object Day18:
def part2(input: String, example: Boolean = false) =
val area = if example then Area(0 to 6, 0 to 6) else Area(0 to 70, 0 to 70)
val bytes = parse(input)
val lastPossible = bytes.reverse.tails.find(bits =>
val lastPossible = bytes.inits.find(bits =>
pathFind(adjacency(area, bits.toSet), Coord(0, 0), area.bottomRight).isDefined
).get
val impossible = bytes(lastPossible.size)
Expand Down

0 comments on commit bd3e157

Please sign in to comment.