From 288474d2be1164a007fb79b25aae2e3ab086e9b6 Mon Sep 17 00:00:00 2001 From: Flashk Date: Sun, 3 Dec 2023 18:05:59 +0100 Subject: [PATCH] Fix codacy issues --- .../adventofcode/flashk/day03/GearRatios.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/adventofcode/flashk/day03/GearRatios.java b/src/main/java/com/adventofcode/flashk/day03/GearRatios.java index 141cc25..91ee4e9 100644 --- a/src/main/java/com/adventofcode/flashk/day03/GearRatios.java +++ b/src/main/java/com/adventofcode/flashk/day03/GearRatios.java @@ -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 { @@ -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 = 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 @@ -71,7 +77,7 @@ private int processNumber(int row, int col) { saveOrUpdateSymbol(symbol.get(), calculatedPartNumber); } - return col; + return currentCol; }