Skip to content

Commit 1642769

Browse files
committed
Prematurely optimize 2024 day 25 part 1
1 parent 3f4f716 commit 1642769

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

src/main/scala/eu/sim642/adventofcode2024/Day25.scala

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ object Day25 {
1313

1414
def countLockKeyFits(lockKeys: Seq[Grid[Boolean]]): Int = {
1515
val (keys, locks) = lockKeys.partition(isKey)
16-
(for {
17-
key <- keys
18-
lock <- locks
19-
if fits(key, lock)
20-
} yield ()).size
16+
keys.view.map(key => locks.count(fits(key, _))).sum
2117
}
2218

2319
def parseLockKey(s: String): Grid[Boolean] = s.linesIterator.map(_.map(_ == '#').toVector).toVector

0 commit comments

Comments
 (0)