Skip to content

Commit

Permalink
Fix codacy issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Flashky committed Dec 3, 2023
1 parent 0871b4f commit 288474d
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/main/java/com/adventofcode/flashk/day03/GearRatios.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
import com.adventofcode.flashk.common.GridUtil;
import com.adventofcode.flashk.common.Vector2;

import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;


public class GearRatios {

Expand Down Expand Up @@ -52,17 +57,18 @@ private void processGrid() {
private int processNumber(int row, int col) {

StringBuilder number = new StringBuilder();
int currentCol = col;

// Find number and symbol if present
Optional<Symbol> symbol = Optional.empty();
while(col < cols && Character.isDigit(engine[row][col])) {
number.append(engine[row][col]);
while(currentCol < cols && Character.isDigit(engine[row][currentCol])) {
number.append(engine[row][currentCol]);

if(symbol.isEmpty()) {
symbol = findSymbol(row, col);
symbol = findSymbol(row, currentCol);
}

col++;
currentCol++;
}

// If current number has a symbol, update data structures
Expand All @@ -71,7 +77,7 @@ private int processNumber(int row, int col) {
saveOrUpdateSymbol(symbol.get(), calculatedPartNumber);
}

return col;
return currentCol;

}

Expand Down

0 comments on commit 288474d

Please sign in to comment.