Skip to content

Commit ff8014d

Browse files
authored
day 25 code (#812)
1 parent 9e56af6 commit ff8014d

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

2024/src/day25.scala

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package day25
2+
3+
import locations.Directory.currentDir
4+
import inputs.Input.loadFileSync
5+
6+
@main def part1: Unit =
7+
println(s"The solution is ${part1(loadInput())}")
8+
9+
def loadInput(): String = loadFileSync(s"$currentDir/../input/day25")
10+
11+
def part1(input: String): Int =
12+
val (locks, keys) = input.split("\n\n").partition(_.startsWith("#"))
13+
14+
val matches = for
15+
lock <- locks
16+
key <- keys
17+
if lock.zip(key).forall: (lockChar, keyChar) =>
18+
lockChar != '#' || keyChar != '#'
19+
yield lock -> key
20+
21+
matches.length

0 commit comments

Comments
 (0)