Files
advent-of-code-2024/15/WarehouseWoes/Program.cs
T

32 lines
738 B
C#
Raw Normal View History

2024-12-15 17:22:38 -06:00
using System.Diagnostics;
2024-12-16 23:51:43 -06:00
using WarehouseWoes;
2024-12-15 17:22:38 -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";
var input = await File.ReadAllTextAsync(args[0]);
2024-12-15 17:22:38 -06:00
var stopwatch = new Stopwatch();
stopwatch.Start();
2024-12-16 23:51:43 -06:00
var (parsedMap, directions) = PuzzleParser.Parse(input);
var map = isPart2
? parsedMap.Scale()
: parsedMap;
var result = map.MoveRobot(directions).CalculateTotalBoxGpsCoordinates();
2024-12-15 17:22:38 -06:00
stopwatch.Stop();
2024-12-16 23:51:43 -06:00
Console.WriteLine($"The sum of all boxes' GPS coordinates is {result}. ({stopwatch.ElapsedMilliseconds}ms)");