diff --git a/src/aoc2024/Day03.kt b/src/aoc2024/Day03.kt index 4035dee..99953f5 100644 --- a/src/aoc2024/Day03.kt +++ b/src/aoc2024/Day03.kt @@ -22,7 +22,7 @@ fun main() { xmul(2,4)%&mul[3,7]!@^do_not_mul(5,5)+mul(32,64]then(mul(11,8)mul(8,5)) """ val inlineTestInput2 = """ -xmul(2,4)&mul[3,7]!^don't()_mul(5,5)+mul(32,64](mul(11,8)undo()?mul(8,5) +xmul(2,4)&mul[3,7]!^don't()_mul(5,5)+mul(32,64](mul(11,8)undo()?mul(8,5)don't()mul(10,10) """ fun part1(input: List): Int { @@ -32,7 +32,7 @@ xmul(2,4)&mul[3,7]!^don't()_mul(5,5)+mul(32,64](mul(11,8)undo()?mul(8,5) fun part2(input: List): Int { return "mul\\((\\d+),(\\d+)\\)".toRegex() - .findAll(input.joinToString("").replace("(don't\\(\\).*?)+do\\(\\)".toRegex(), "")) + .findAll((input.joinToString("") + "do()").replace("(don't\\(\\).*?)+(do\\(\\)|$)".toRegex(), "")) .sumOf { it.groupValues[1].toInt() * it.groupValues[2].toInt() } }