Skip to content

Commit

Permalink
2024-21 Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jurisk committed Dec 21, 2024
1 parent da8b5a5 commit 85b8d9c
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions scala2/src/main/scala/jurisk/adventofcode/y2024/Advent21.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,9 @@ object Advent21 {
invalid: Coords2D,
): Set[List[DirectionalButton]] = {
def validDirections(directions: List[DirectionalButton]): Boolean = {
var coords = current
directions foreach { d =>
val diff = d.actionDiff
coords += diff
if (coords == invalid) {
return false
}
}
true
!directions.scanLeft(current) { (coords, d) =>
coords + d.actionDiff
}.contains(invalid)
}

val diff = toPress - current
Expand Down Expand Up @@ -100,6 +94,7 @@ object Advent21 {
def pathTo(toPress: NumericButton): Set[List[DirectionalButton]] =
pathBetweenCoords(this.coords, toPress.coords, InvalidNumericCoords)
}

object NumericButton {
private val InvalidNumericCoords: Coords2D = Coords2D(0, 3)

Expand Down

0 comments on commit 85b8d9c

Please sign in to comment.