Skip to content

Commit

Permalink
[2024/6] Remove redundant parentheses
Browse files Browse the repository at this point in the history
  • Loading branch information
pfolta committed Dec 6, 2024
1 parent 039a063 commit 421f69f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main/kotlin/adventofcode/year2024/Day06GuardGallivant.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ class Day06GuardGallivant(customInput: PuzzleInput? = null) : Puzzle(customInput

override fun partOne() =
generateSequence(guard to setOf(guard.first)) { (previousGuard, previousVisited) ->
val nextPosition = (previousGuard.first + previousGuard.second.direction)
val nextPosition = previousGuard.first + previousGuard.second.direction

when {
nextPosition in obstructions -> (previousGuard.first to previousGuard.second.turnRight()) to (previousVisited)
else -> (nextPosition to previousGuard.second) to (previousVisited + previousGuard.first)
nextPosition in obstructions -> previousGuard.first to previousGuard.second.turnRight() to previousVisited
else -> nextPosition to previousGuard.second to previousVisited + previousGuard.first
}
}
.first { (guard, _) -> guard.first.toList().any { it !in grid.indices } }
Expand Down

0 comments on commit 421f69f

Please sign in to comment.