Skip to content

Commit

Permalink
day 22 part 1
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaKateryna committed Dec 22, 2024
1 parent dedfdf6 commit 2804a9c
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions AdventOfCode/Day22.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

namespace AdventOfCode;

public class Day22 : BaseDay
{
public override ValueTask<string> Solve_1()
{
long[] numbers = File.ReadAllLines(InputFilePath).Select(long.Parse).ToArray();

long result = numbers.Sum(n => GetIteration(n, 2000));

return new(result.ToString());
}

public override ValueTask<string> Solve_2()
{
return new("");
}

private long GetIteration(long number, int iterations)
{
for (int i = 0; i < iterations; ++i)
{
// 1
number = (number << 6) ^ number;
number = number % 16777216;

// 2
number = (number / 32) ^ number;
number = number % 16777216;

// 3
number = (number << 11) ^ number;
number = number % 16777216;
}

return number;
}
}

0 comments on commit 2804a9c

Please sign in to comment.