Refactor Day12 to remove redundant Where in presentSizes calculation and adjust method modifier for GetMinTotalPresentArea
This commit is contained in:
+1
-2
@@ -16,7 +16,6 @@ public class Day12 : IPuzzleSolver<long>
|
|||||||
.Split($"{Environment.NewLine}{Environment.NewLine}", StringSplitOptions.TrimEntries)
|
.Split($"{Environment.NewLine}{Environment.NewLine}", StringSplitOptions.TrimEntries)
|
||||||
.ToList();
|
.ToList();
|
||||||
var presentSizes = puzzleInput[..^1]
|
var presentSizes = puzzleInput[..^1]
|
||||||
.Where(s => !string.IsNullOrWhiteSpace(s))
|
|
||||||
.Select(s => s.Count(c => c == '#'))
|
.Select(s => s.Count(c => c == '#'))
|
||||||
.ToArray();
|
.ToArray();
|
||||||
var regions = puzzleInput[^1]
|
var regions = puzzleInput[^1]
|
||||||
@@ -37,7 +36,7 @@ public class Day12 : IPuzzleSolver<long>
|
|||||||
return everythingFits;
|
return everythingFits;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int GetMinTotalPresentArea(int[] presentCounts, int[] presentSizes)
|
private int GetMinTotalPresentArea(int[] presentCounts, int[] presentSizes)
|
||||||
{
|
{
|
||||||
return presentCounts
|
return presentCounts
|
||||||
.Select((presentCount, index) => presentCount * presentSizes[index])
|
.Select((presentCount, index) => presentCount * presentSizes[index])
|
||||||
|
|||||||
Reference in New Issue
Block a user