Skip to content

Commit 3d8dbe8

Browse files
committed
2022/Day 15
1 parent 1782999 commit 3d8dbe8

File tree

1 file changed

+3
-2
lines changed
  • src/main/kotlin/me/grison/aoc/y2022

1 file changed

+3
-2
lines changed

src/main/kotlin/me/grison/aoc/y2022/Day15.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ class Day15 : Day(15, 2022) {
3232

3333
override fun partTwo(): Long {
3434
val data = data()
35+
val max = 4_000_000L
3536

36-
for (i in 3_000_000L..4_000_000L) {
37+
for (i in (max - 1_000_000L)..max) {
3738
val bounds = mutableListOf<LPosition>()
3839
for ((sensor, beacon) in data) {
3940
val distance = sensor.manhattan(beacon)
@@ -46,7 +47,7 @@ class Day15 : Day(15, 2022) {
4647
var last = 0L
4748
for ((bx, by) in bounds) {
4849
if (bx > last)
49-
return i * 4_000_000L + bx.dec()
50+
return i * max + bx.dec()
5051
last = max(last, by);
5152
}
5253
}

0 commit comments

Comments
 (0)