Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fun partOne() {
- println("[2024] Day three, part one...")
- val input = input()
- val regex = "mul\\(\\d+,\\d+\\)".toRegex()
- val validMuls = regex.findAll(input)
- .map {
- val values = it.value
- .substringAfter("(")
- .substringBeforeLast(")")
- .split(",")
- .map { it.toLong() }
- values[0] to values[1]
- }.toMutableList()
- val result = validMuls.sumOf { it.first * it.second }
- println("Result: $result")
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement