Refactor Day04 and Day09 to rename methods and variables for improved clarity and update Day09 tests with additional input file and test case
This commit is contained in:
+2
-3
@@ -55,13 +55,12 @@ public class Day04 : IPuzzleSolver<long>
|
||||
private HashSet<Coordinate> GetRollCoordinates(IEnumerable<string> paperrollGrid)
|
||||
{
|
||||
var coordinates = paperrollGrid
|
||||
.Index()
|
||||
.SelectMany(indexedLine => GetCoordinates(indexedLine.Item, indexedLine.Index))
|
||||
.SelectMany((line, xIndex) => GetRollCoordinates(line, xIndex))
|
||||
.ToHashSet();
|
||||
return coordinates;
|
||||
}
|
||||
|
||||
private IEnumerable<Coordinate> GetCoordinates(string gridLine, int xIndex)
|
||||
private IEnumerable<Coordinate> GetRollCoordinates(string gridLine, int xIndex)
|
||||
{
|
||||
var indexedCharacters = gridLine.Index();
|
||||
var validRolls = indexedCharacters.Where(tuple => tuple.Item == '@');
|
||||
|
||||
+2
-1
@@ -64,7 +64,8 @@ public class Day09 : IPuzzleSolver<long>
|
||||
|
||||
private bool IsRectangleInsideBorders(CoordinatePair[] borders, CoordinatePair rectangle)
|
||||
{
|
||||
return !borders.Any(border => RectangleCrossesBorder(rectangle, border));
|
||||
var bordersCrossed = borders.Any(border => RectangleCrossesBorder(rectangle, border));
|
||||
return !bordersCrossed;
|
||||
}
|
||||
|
||||
private CoordinatePair AsPair(Coordinate a, Coordinate b)
|
||||
|
||||
Reference in New Issue
Block a user