@@ -18,7 +18,6 @@ package adventofcode.day14
18
18
19
19
import adventofcode.util.geom.plane.Point2D
20
20
import adventofcode.util.geom.plane.Ray
21
- import adventofcode.util.grid.TextGrid
22
21
import adventofcode.util.lcmInt
23
22
import adventofcode.util.occurrences
24
23
import adventofcode.util.removeAll
@@ -69,14 +68,6 @@ fun String.calculateSafetyFactorAt(t: Int): Int {
69
68
return robots.map { it.move(t, maxX, maxY) }.safetyFactor(maxX, maxY)
70
69
}
71
70
72
- fun Set<Point2D>.printGrid (maxX : Int , maxY : Int ) {
73
- val grid = TextGrid (" ." .repeat(maxX * maxY).chunked(maxX))
74
- forEach { (x, y) ->
75
- grid[x, y] = ' #'
76
- }
77
- println (grid)
78
- }
79
-
80
71
fun List<Point2D>.calculateShannonEntropy (maxX : Int , maxY : Int , gridWidth : Int , gridHeight : Int ): Double {
81
72
val cellWidth = maxX.toDouble() / gridWidth
82
73
val cellHeight = maxY.toDouble() / gridHeight
@@ -101,7 +92,7 @@ fun String.findTree(): Int {
101
92
val maxX = robots.maxOf { it.ray.origin.x } + 1
102
93
val maxY = robots.maxOf { it.ray.origin.y } + 1
103
94
val sequences = robots.map { it.points(maxX, maxY) }
104
- val minEntropyT = (1 .. lcmInt(maxX, maxY)).minBy { t ->
95
+ val minEntropyT = (1 .. lcmInt(maxX, maxY)).minBy { _ ->
105
96
sequences.map { it.next() }.calculateShannonEntropy(maxX, maxY, GRID_WIDTH , GRID_HEIGHT )
106
97
}
107
98
return minEntropyT
0 commit comments