Skip to content

Commit ebf5783

Browse files
committed
Fixed issue with day 10 algorithm.
1 parent 7806dd9 commit ebf5783

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/main/kotlin/day10/day10.kt

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
package day10
55

66
import common.aocreader.fetchAdventOfCodeInput
7-
import common.gridalgorithms.neighbourPositions
7+
import common.gridalgorithms.*
88
import common.intpos2d.*
99
import common.runner.timedFunction
1010

@@ -34,8 +34,7 @@ private fun findTrails(grid: List<List<Int>>): Map<IntPos2D, Trails> {
3434

3535
// Try all the valid neighbours.
3636
val neighbours = grid.neighbourPositions(currentPos)
37-
// val neighbours = currentPos.neighbours(rows, cols)
38-
// .filter { coords -> grid[coords.first][coords.second] == currHeight + 1 }
37+
.filter { (grid[it] ?: -1L) == currHeight + 1 }
3938
if (neighbours.isEmpty()) return emptySet()
4039

4140
return neighbours.flatMap { pos -> aux(trailSoFar + pos) }.toSet()

0 commit comments

Comments
 (0)