small refactorings

This commit is contained in:
Sebastian Lindemeier 2025-12-05 09:45:02 +01:00
parent 31caf429ca
commit 79541d0dae
3 changed files with 3 additions and 28 deletions

View File

@ -73,24 +73,6 @@ public class Day01 : IPuzzleSolver<int>
return mod; 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) private static int ParseRotationAmount(string puzzleInput)
{ {
var direction = puzzleInput[..1]; var direction = puzzleInput[..1];
@ -102,11 +84,4 @@ public class Day01 : IPuzzleSolver<int>
return rotationAmount; return rotationAmount;
} }
private static int CountFullRotations(int rotationAmount)
{
var fullRotations = Math.Abs(rotationAmount / 100);
return fullRotations;
}
} }

View File

@ -81,8 +81,8 @@ public class Day04 : IPuzzleSolver<long>
Coordinate[] neighbourDirections = Coordinate[] neighbourDirections =
[ [
(-1, -1), (-1, 0), (-1, 1), (-1, -1), (-1, 0), (-1, 1),
(0, -1), (0, 1), (0, -1), (0, 1),
(1, -1), (1, 0), (1, 1), (1, -1), (1, 0), (1, 1),
]; ];
var possibleNeighbours = neighbourDirections var possibleNeighbours = neighbourDirections
.Select(direction => (coordinate.x + direction.x, coordinate.y + direction.y)); .Select(direction => (coordinate.x + direction.x, coordinate.y + direction.y));

View File

@ -113,7 +113,7 @@ public class Day05 : IPuzzleSolver<long>
return optimizedRanges; 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); var countIdsInRanges = combinedRanges.Select(range => range.to - range.from + 1);
return countIdsInRanges; return countIdsInRanges;