Files
advent-of-code-2024/11/PlutonianPebbles/Program.cs
T

35 lines
780 B
C#
Raw Normal View History

2024-12-11 12:29:33 -06:00
using System.Diagnostics;
2024-12-12 00:01:22 -06:00
using PlutonianPebbles;
2024-12-11 12:29:33 -06:00
if (args.Length is 0)
{
Console.WriteLine("Please provide a path to the input file.");
return;
}
if (File.Exists(args[0]) is false)
{
Console.WriteLine("The provided file does not exist.");
return;
}
var isPart2 = args.Length is 2 && args[1] is "part2";
2024-12-11 13:29:16 -06:00
var input = await File.ReadAllTextAsync(args[0]);
2024-12-11 12:29:33 -06:00
var stopwatch = new Stopwatch();
stopwatch.Start();
2024-12-11 13:29:16 -06:00
var stones = input
.Split(" ", StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries)
.Select(Stone.From)
.ToList();
var observer = Observer.Of(stones);
2024-12-12 00:01:22 -06:00
var times = isPart2 ? 75 : 25;
var result = observer.Blink(times);
2024-12-11 12:29:33 -06:00
stopwatch.Stop();
2024-12-12 00:01:22 -06:00
Console.WriteLine($"The number of stones is {result}. ({stopwatch.ElapsedMilliseconds}ms)");