Skip to content

Commit

Permalink
Simplify Day 9 part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
eduherminio committed Dec 9, 2023
1 parent e141598 commit 73f137e
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/AoC_2023/Day_09.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,12 @@ public override ValueTask<string> Solve_2()
{
var sequences = ReduceToZero(input);

int prediction = sequences[0][0];
for (int i = 1; i < sequences.Count; i++)
for (int i = 0; i < sequences.Count; i++)
{
result += (i % 2 == 0)
? sequences[i][0]
: -sequences[i][0];
result += (i % 2 == 1)
? -sequences[i][0]
: sequences[i][0];
}

result += prediction;
}

return new($"{result}");
Expand Down

0 comments on commit 73f137e

Please sign in to comment.