fix: Fixed Day 2 - part 2 not working yet

This commit is contained in:
henrik
2024-12-03 22:25:41 +01:00
parent fb3a16c772
commit e08b82342b
2 changed files with 6 additions and 7 deletions

View File

@@ -29,7 +29,6 @@ Console.WriteLine(levelsSafe);
bool TestLevel(LinkedList<int> linkedList)
{
int unsafeCount = 0;
var node = linkedList.First;
List<LevelDirection> directions = new List<LevelDirection>();
while (node != null)
@@ -47,7 +46,7 @@ bool TestLevel(LinkedList<int> linkedList)
if(safeRange is false)
{
unsafeCount++;
return false;
}
if (node.Next is not null)
@@ -61,8 +60,7 @@ bool TestLevel(LinkedList<int> linkedList)
bool allIncreasing = directions.All(x => x == LevelDirection.Increasing);
bool allDecreasing = directions.All(x => x == LevelDirection.Decreasing);
Console.Write($" {unsafeCount}|{allIncreasing}|{allDecreasing} ");
return ((allIncreasing || allDecreasing) && unsafeCount == 0) || (allIncreasing == false && allDecreasing == false);
return allIncreasing || allDecreasing;
bool InsideRange(int current, int target)
{