Skip to content

Commit 1c1ec5e

Browse files
committed
Optimizing Ram Run algorithm.
1 parent 41809ad commit 1c1ec5e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ Here are the solutions I have implemented along with the time it took to run eac
3737
| [Day 15: Warehouse Woes](src/test/kotlin/adventofcode/Day15Test.kt) | 129 |
3838
| [Day 16: Reindeer Maze](src/test/kotlin/adventofcode/Day16Test.kt) | 261 |
3939
| [Day 17: Chronospatial Computer](src/test/kotlin/adventofcode/Day17Test.kt) | 93 |
40-
| [Day 18: RAM Run](src/test/kotlin/adventofcode/Day18Test.kt) | 3,328 |
40+
| [Day 18: RAM Run](src/test/kotlin/adventofcode/Day18Test.kt) | 2,608 |
4141
| [Day 19: Linen Layout](src/test/kotlin/adventofcode/Day19Test.kt) | 60 |
4242
| [Day 20: Race Condition](src/test/kotlin/adventofcode/Day20Test.kt) | 0 |

src/main/kotlin/adventofcode/day18/RamRun.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ fun String.findFirstByteThatBlocksExit(): Point2D {
3535
val end = Point2D(xRange.last, yRange.last)
3636
val fallen = mutableSetOf<Point2D>()
3737
val neighbors =
38-
{ p: Point2D -> p.neighbors().filter { it.x in xRange && it.y in yRange }.filter { it !in fallen} }
38+
{ p: Point2D -> p.neighbors().filter { it.x in xRange && it.y in yRange }.filter { it !in fallen } }
3939
return points.first { p ->
4040
fallen.add(p)
41-
Graphs.dfs(start, end, neighbors).isEmpty()
41+
Graphs.bfs(start, end, neighbors).isEmpty()
4242
}
4343
}
4444

0 commit comments

Comments
 (0)