small refactorings
This commit is contained in:
parent
31caf429ca
commit
79541d0dae
|
|
@ -73,24 +73,6 @@ public class Day01 : IPuzzleSolver<int>
|
|||
return mod;
|
||||
}
|
||||
|
||||
private static bool HasPassedZero(bool hasOverflow, int dialPosition)
|
||||
{
|
||||
return dialPosition != 0 && hasOverflow;
|
||||
}
|
||||
|
||||
private static (int nextDialPosition, bool passedZero) GetNextDialPosition(int rotationAmount, int dialPosition)
|
||||
{
|
||||
var actualRotation = rotationAmount % 100;
|
||||
var nextDialPosition = dialPosition + actualRotation;
|
||||
var hasOverflow = nextDialPosition is > 99 or < 1;
|
||||
nextDialPosition %= 100;
|
||||
if (nextDialPosition < 0)
|
||||
{
|
||||
nextDialPosition = 100 + nextDialPosition;
|
||||
}
|
||||
return (nextDialPosition, hasOverflow);
|
||||
}
|
||||
|
||||
private static int ParseRotationAmount(string puzzleInput)
|
||||
{
|
||||
var direction = puzzleInput[..1];
|
||||
|
|
@ -102,11 +84,4 @@ public class Day01 : IPuzzleSolver<int>
|
|||
|
||||
return rotationAmount;
|
||||
}
|
||||
|
||||
private static int CountFullRotations(int rotationAmount)
|
||||
{
|
||||
var fullRotations = Math.Abs(rotationAmount / 100);
|
||||
|
||||
return fullRotations;
|
||||
}
|
||||
}
|
||||
|
|
@ -81,8 +81,8 @@ public class Day04 : IPuzzleSolver<long>
|
|||
Coordinate[] neighbourDirections =
|
||||
[
|
||||
(-1, -1), (-1, 0), (-1, 1),
|
||||
(0, -1), (0, 1),
|
||||
(1, -1), (1, 0), (1, 1),
|
||||
(0, -1), (0, 1),
|
||||
(1, -1), (1, 0), (1, 1),
|
||||
];
|
||||
var possibleNeighbours = neighbourDirections
|
||||
.Select(direction => (coordinate.x + direction.x, coordinate.y + direction.y));
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ public class Day05 : IPuzzleSolver<long>
|
|||
return optimizedRanges;
|
||||
}
|
||||
|
||||
private static IEnumerable<long> CountIdsInRanges(List<Range> combinedRanges)
|
||||
private static IEnumerable<long> CountIdsInRanges(IEnumerable<Range> combinedRanges)
|
||||
{
|
||||
var countIdsInRanges = combinedRanges.Select(range => range.to - range.from + 1);
|
||||
return countIdsInRanges;
|
||||
|
|
|
|||
Loading…
Reference in New Issue