Skip to content

Commit 16fa1b1

Browse files
committed
Refactor Y2024D04.
Micro-optimize word checking.
1 parent e51f815 commit 16fa1b1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Diff for: solutions/aockt/y2024/Y2024D04.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,13 @@ object Y2024D04 : Solution {
3737
}
3838

3939
override fun partTwo(input: String): Int = with(parseInput(input)) {
40+
val mas = setOf("MAS", "SAM")
4041
points()
4142
.filter { (p, v) -> v == 'A' && p.x in 1..<width - 1 && p.y in 1..<height - 1 }
4243
.count { (p, v) ->
4344
val mainDiag = "${get(p.move(Left).move(Up))}$v${get(p.move(Right).move(Down))}"
4445
val sideDiag = "${get(p.move(Right).move(Up))}$v${get(p.move(Left).move(Down))}"
45-
with("MAS|SAM") { mainDiag in this && sideDiag in this }
46+
mainDiag in mas && sideDiag in mas
4647
}
4748
}
4849
}

0 commit comments

Comments
 (0)