Refactor Day07 to rename variables and fix return type for timeline count methods
This commit is contained in:
+6
-6
@@ -29,15 +29,15 @@ public class Day07 : IPuzzleSolver<long>
|
|||||||
{
|
{
|
||||||
var grid = ParsePuzzleInput(pathToPuzzleInput);
|
var grid = ParsePuzzleInput(pathToPuzzleInput);
|
||||||
var start = GetStart(grid);
|
var start = GetStart(grid);
|
||||||
var nodesWithCount = GetTimelinesCountRecursive(grid, start, []);
|
var timelinesCount = GetTimelinesCountRecursive(grid, start, []);
|
||||||
return nodesWithCount;
|
return timelinesCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long SolvePart2Again(string pathToPuzzleInput)
|
public long SolvePart2Again(string pathToPuzzleInput)
|
||||||
{
|
{
|
||||||
var grid = ParsePuzzleInput(pathToPuzzleInput);
|
var grid = ParsePuzzleInput(pathToPuzzleInput);
|
||||||
var nodesWithCount = GetTimelinesCount(grid);
|
var timelinesCount = GetTimelinesCount(grid);
|
||||||
return nodesWithCount.Sum();
|
return timelinesCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Coordinate GetStart(string[] grid)
|
private Coordinate GetStart(string[] grid)
|
||||||
@@ -98,7 +98,7 @@ public class Day07 : IPuzzleSolver<long>
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
private long[] GetTimelinesCount(string[] grid)
|
private long GetTimelinesCount(string[] grid)
|
||||||
{
|
{
|
||||||
var numbersGrid = grid
|
var numbersGrid = grid
|
||||||
.Select(line => line.Select(c => 0L).ToArray())
|
.Select(line => line.Select(c => 0L).ToArray())
|
||||||
@@ -125,6 +125,6 @@ public class Day07 : IPuzzleSolver<long>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return numbersGrid[^1];
|
return numbersGrid[^1].Sum();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user