Skip to content

Commit

Permalink
aoc 2024 day 3 refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCK committed Dec 3, 2024
1 parent 64214f1 commit 63a9e0d
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,16 @@ private void run(final Scanner in, final boolean enableDisable) {

long sum = 0;
while (matcher.find(index)) {
if (enableDisable && deactivationMatcher.find(index)) {
if (deactivationMatcher.start() < matcher.start()) {
if (activeMatcher.find(deactivationMatcher.start())) {
index = activeMatcher.end();
continue;
}
if (enableDisable
&& deactivationMatcher.find(index)
&& deactivationMatcher.start() < matcher.start()) {

break;
if (activeMatcher.find(deactivationMatcher.start())) {
index = activeMatcher.end();
continue;
}

break;
}

final long one = Long.parseLong(matcher.group("one"));
Expand All @@ -70,7 +71,6 @@ private static String readInput(final Scanner in) {
builder.append(in.nextLine());
}

final String input = builder.toString();
return input;
return builder.toString();
}
}

0 comments on commit 63a9e0d

Please sign in to comment.