Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions 2024/src/main/scala/aoc2024/Day23.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ object Day23 extends AoC:

type N = String

lazy val edges: Set[(String, String)] =
lazy val edges: Set[(N, N)] =

val directed = lines.toSet.map:
case s"$a-$b" => (a,b)

directed ++ directed.map(_.swap)

lazy val neighbours: Map[N,Set[N]] =
lazy val neighbours: Map[N, Set[N]] =
edges.groupMap(_.left)(_.right)

lazy val solve1: Set[Set[N]] =
for
(a,b) <- edges
c <- neighbours(a) intersect neighbours(b)
(a, b) <- edges
c <- neighbours(a) intersect neighbours(b)
if a.startsWith("t") || b.startsWith("t") || c.startsWith("t")
yield
Set(a,b,c)
Set(a, b, c)

override lazy val answer1: Long = solve1.size
override lazy val answer2: String = BronKerbosch.run(neighbours).toVector.sorted.mkString(",")