diff --git a/.github/workflows/sbt.yml b/.github/workflows/sbt.yml index b7324597..7324cc23 100644 --- a/.github/workflows/sbt.yml +++ b/.github/workflows/sbt.yml @@ -21,7 +21,7 @@ jobs: run: sbt test deps: - # if: github.head_ref == 'master' + if: github.ref == 'refs/heads/master' runs-on: ubuntu-latest diff --git a/src/main/scala/eu/sim642/adventofcode2019/Day18.scala b/src/main/scala/eu/sim642/adventofcode2019/Day18.scala index 67855209..b083cccc 100644 --- a/src/main/scala/eu/sim642/adventofcode2019/Day18.scala +++ b/src/main/scala/eu/sim642/adventofcode2019/Day18.scala @@ -23,6 +23,7 @@ object Day18 { trait KeyNeighborsSolution extends Solution { case class PathData(distance: Int, pathDoors: Set[Pos], pathKeys: Set[Pos]) + // https://en.wikipedia.org/wiki/Transit_node_routing def getKeyNeighbors(input: Input): collection.Map[Pos, collection.Map[Pos, PathData]] override def collectKeysSteps(input: Input): Int = { diff --git a/src/main/scala/eu/sim642/adventofcode2021/Day23.scala b/src/main/scala/eu/sim642/adventofcode2021/Day23.scala index 78440534..569869ad 100644 --- a/src/main/scala/eu/sim642/adventofcode2021/Day23.scala +++ b/src/main/scala/eu/sim642/adventofcode2021/Day23.scala @@ -33,6 +33,7 @@ object Day23 { private case class PathData(length: Int, pathPoss: Set[Pos]) + // https://en.wikipedia.org/wiki/Transit_node_routing private val posNeighbors: collection.Map[Pos, collection.Map[Pos, PathData]] = { val allPoss: Set[Pos] = hallways ++ room2amphipod.keySet diff --git a/src/main/scala/eu/sim642/adventofcode2022/Day16.scala b/src/main/scala/eu/sim642/adventofcode2022/Day16.scala index 5621fecc..0f08baea 100644 --- a/src/main/scala/eu/sim642/adventofcode2022/Day16.scala +++ b/src/main/scala/eu/sim642/adventofcode2022/Day16.scala @@ -12,6 +12,7 @@ object Day16 { case class ValveData(flowRate: Int, tunnels: Seq[Valve]) + // https://en.wikipedia.org/wiki/Transit_node_routing def valveDists(valves: Map[Valve, ValveData]): collection.Map[Valve, collection.Map[Valve, Int]] = { val dists: mutable.Map[Valve, mutable.Map[Valve, Int]] = valves.view.mapValues(_.tunnels.map(_ -> 1).to(mutable.Map)).to(mutable.Map) // Floyd-Warshall diff --git a/src/main/scala/eu/sim642/adventofcode2024/Day25.scala b/src/main/scala/eu/sim642/adventofcode2024/Day25.scala index c74ccb1a..6607a194 100644 --- a/src/main/scala/eu/sim642/adventofcode2024/Day25.scala +++ b/src/main/scala/eu/sim642/adventofcode2024/Day25.scala @@ -13,11 +13,7 @@ object Day25 { def countLockKeyFits(lockKeys: Seq[Grid[Boolean]]): Int = { val (keys, locks) = lockKeys.partition(isKey) - (for { - key <- keys - lock <- locks - if fits(key, lock) - } yield ()).size + keys.view.map(key => locks.count(fits(key, _))).sum } def parseLockKey(s: String): Grid[Boolean] = s.linesIterator.map(_.map(_ == '#').toVector).toVector