Skip to content

Commit

Permalink
2024 - Day 08 - Even simpler initial values for generateSequence.
Browse files Browse the repository at this point in the history
  • Loading branch information
fmmr committed Dec 8, 2024
1 parent 5a0d6fc commit 898b22f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/kotlin/no/rodland/advent_2024/Day08.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class Day08(val input: List<String>) : Day<Int, Int, Pair<Array<CharArray>, Map<

private fun Pair<Pos, Pos>.antinodes2(): Set<Pos> {
return (second - first).let { diff ->
val forward = generateSequence(first + diff) { it + diff }.takeWhile { it in grid }
val backwards = generateSequence(second - diff) { it - diff }.takeWhile { it in grid }
val forward = generateSequence(second) { it + diff }.takeWhile { it in grid }
val backwards = generateSequence(first) { it - diff }.takeWhile { it in grid }
(forward + backwards).toSet()
}
}
Expand Down

0 comments on commit 898b22f

Please sign in to comment.