Skip to content

Commit

Permalink
day 25 code
Browse files Browse the repository at this point in the history
  • Loading branch information
merlinorg committed Dec 25, 2024
1 parent 9e56af6 commit 99f5a9f
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions 2024/src/day25.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package day25

import locations.Directory.currentDir
import inputs.Input.loadFileSync

@main def part1: Unit =
println(s"The solution is ${part1(loadInput())}")

def loadInput(): String = loadFileSync(s"$currentDir/../input/day25")

def part1(input: String): Long =
val (locks, keys) = input.split("\n\n").partition(_.startsWith("#"))

val matches = for
lock <- locks
key <- keys
if lock.zip(key).forall: (lockChar, keyChar) =>
lockChar != '#' || keyChar != '#'
yield lock -> key

matches.length

0 comments on commit 99f5a9f

Please sign in to comment.