Skip to content

Commit 697df37

Browse files
committed
Fixing sonar issues.
1 parent d1edd9b commit 697df37

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

src/main/kotlin/adventofcode/day14/RestroomRedoubt.kt

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package adventofcode.day14
1818

1919
import adventofcode.util.geom.plane.Point2D
2020
import adventofcode.util.geom.plane.Ray
21-
import adventofcode.util.grid.TextGrid
2221
import adventofcode.util.lcmInt
2322
import adventofcode.util.occurrences
2423
import adventofcode.util.removeAll
@@ -69,14 +68,6 @@ fun String.calculateSafetyFactorAt(t: Int): Int {
6968
return robots.map { it.move(t, maxX, maxY) }.safetyFactor(maxX, maxY)
7069
}
7170

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-
8071
fun List<Point2D>.calculateShannonEntropy(maxX: Int, maxY: Int, gridWidth: Int, gridHeight: Int): Double {
8172
val cellWidth = maxX.toDouble() / gridWidth
8273
val cellHeight = maxY.toDouble() / gridHeight
@@ -101,7 +92,7 @@ fun String.findTree(): Int {
10192
val maxX = robots.maxOf { it.ray.origin.x } + 1
10293
val maxY = robots.maxOf { it.ray.origin.y } + 1
10394
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 { _ ->
10596
sequences.map { it.next() }.calculateShannonEntropy(maxX, maxY, GRID_WIDTH, GRID_HEIGHT)
10697
}
10798
return minEntropyT

0 commit comments

Comments
 (0)