Skip to content

Commit

Permalink
[2024/7] Use built-in Kotlin operator functions
Browse files Browse the repository at this point in the history
  • Loading branch information
pfolta committed Dec 7, 2024
1 parent 2058e07 commit 020ccd1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/kotlin/adventofcode/year2024/Day07BridgeRepair.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ class Day07BridgeRepair(customInput: PuzzleInput? = null) : Puzzle(customInput)
}
}

override fun partOne() = equations.calibrationResult(setOf({ a, b -> a + b }, { a, b -> a * b }))
override fun partOne() = equations.calibrationResult(setOf(Long::plus, Long::times))

override fun partTwo() = equations.calibrationResult(setOf({ a, b -> a + b }, { a, b -> a * b }, { a, b -> "$a$b".toLong() }))
override fun partTwo() = equations.calibrationResult(setOf(Long::plus, Long::times, { a, b -> "$a$b".toLong() }))

companion object {
private fun List<Pair<Long, List<Long>>>.calibrationResult(operators: Set<(Long, Long) -> Long>) =
Expand Down

0 comments on commit 020ccd1

Please sign in to comment.