day one part one
This commit is contained in:
@@ -1 +1,6 @@
|
|||||||
Console.WriteLine("Advent of Code 2025");
|
using AdventOfCode2025;
|
||||||
|
|
||||||
|
Console.WriteLine("Advent of Code 2025");
|
||||||
|
|
||||||
|
var dayOneInput = await File.ReadAllTextAsync("./Input/DayOne.txt");
|
||||||
|
AdventSolver<SecretEntrance>.Solve(dayOneInput, 1, "Secret Entrance");
|
||||||
22
AdventOfCode2025/SecretEntrance.cs
Normal file
22
AdventOfCode2025/SecretEntrance.cs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
namespace AdventOfCode2025;
|
||||||
|
|
||||||
|
public class SecretEntrance : IAdventSolution
|
||||||
|
{
|
||||||
|
public AdventSolution Solve(string input)
|
||||||
|
{
|
||||||
|
var lines = input.Split('\n', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
|
||||||
|
|
||||||
|
var current = 50;
|
||||||
|
var password = 0;
|
||||||
|
foreach (var line in lines)
|
||||||
|
{
|
||||||
|
var direction = line[0] == 'L' ? -1 : 1;
|
||||||
|
var distance = int.Parse(line.Substring(1)) * direction;
|
||||||
|
current += distance;
|
||||||
|
current %= 100;
|
||||||
|
if(current == 0) password++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new AdventSolution(password.ToString(), null);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user