small refactorings
This commit is contained in:
parent
31caf429ca
commit
79541d0dae
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue