Skip to content

Commit

Permalink
refactor: shorter size.contains
Browse files Browse the repository at this point in the history
  • Loading branch information
scarf005 committed Dec 8, 2024
1 parent 62968c8 commit 6431f13
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions 2024/day08.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ case class Context(size: Size, antennaes: Map[Char, Vector[Pos]]):
antennaes.values.flatMap(_.combinationsN(2).flatMap(fn)).toSet

lazy val part1 =
solve((a, b) => Vector(a + (a - b), b + (b - a))).filter(size.contains).size
solve((a, b) => Vector(a + (a - b), b + (b - a))).filter(size(_)).size
lazy val part2 = solve((a, b) =>
(a deltas b).takeWhile(size.contains)
++ (b deltas a).takeWhile(size.contains),
(a deltas b).takeWhile(size(_)) ++ (b deltas a).takeWhile(size(_)),
).size

object Context:
Expand Down

0 comments on commit 6431f13

Please sign in to comment.