Skip to content

Commit

Permalink
2024 Day 03 Part 2 - check inDoMode before matching regex
Browse files Browse the repository at this point in the history
  • Loading branch information
fmmr committed Dec 3, 2024
1 parent 9d93c33 commit 00c5310
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/kotlin/no/rodland/advent_2024/Day03.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Day03(val input: List<String>) : Day<Long, Long, List<String>> {
when {
mr.value == "do()" -> inDoMode = true
mr.value == "don't()" -> inDoMode = false
multRegEx.matches(mr.value) && inDoMode -> yield(mr.groupValues[1].toInt() * mr.groupValues[2].toInt())
inDoMode && multRegEx.matches(mr.value) -> yield(mr.groupValues[1].toInt() * mr.groupValues[2].toInt())
}
}
}
Expand Down

0 comments on commit 00c5310

Please sign in to comment.