File tree Expand file tree Collapse file tree 1 file changed +2
-6
lines changed
src/main/kotlin/me/peckb/aoc/_2024/calendar/day03 Expand file tree Collapse file tree 1 file changed +2
-6
lines changed Original file line number Diff line number Diff line change @@ -18,15 +18,11 @@ class Day03 @Inject constructor(
1818 var enabled = true
1919
2020 lines.sumOf { line ->
21- val mulMatches = " mul\\ ((?<d1>\\ d+),(?<d2>\\ d+)\\ )" .toRegex().findAll(line)
22- val doMatches = " do\\ (\\ )" .toRegex().findAll(line)
23- val dontMatches = " don\' t\\ (\\ )" .toRegex().findAll(line)
24-
25- val sortedMatches = (mulMatches + doMatches + dontMatches).sortedBy { it.range.first }
21+ val matches = " mul\\ ((?<d1>\\ d+),(?<d2>\\ d+)\\ )|do\\ (\\ )|don\' t\\ (\\ )" .toRegex().findAll(line)
2622
2723 var count = 0L
2824
29- sortedMatches .forEach { match ->
25+ matches .forEach { match ->
3026 when (match.value.take(3 )) {
3127 " do(" -> enabled = true
3228 " don" -> enabled = false
You can’t perform that action at this time.
0 commit comments