feat: solved day 13 part 1 and part 2

This commit is contained in:
Stevan Freeborn
2024-12-14 12:58:28 -06:00
parent 46976b049c
commit abfa9e50ba
6 changed files with 312 additions and 3 deletions
+14 -3
View File
@@ -1,5 +1,7 @@
using System.Diagnostics;
using ClawContraption;
if (args.Length is 0)
{
Console.WriteLine("Please provide a path to the input file.");
@@ -13,12 +15,21 @@ if (File.Exists(args[0]) is false)
}
var isPart2 = args.Length is 2 && args[1] is "part2";
var input = await File.ReadAllLinesAsync(args[0]);
var input = await File.ReadAllTextAsync(args[0]);
var stopwatch = new Stopwatch();
stopwatch.Start();
// TODO: Implement solution
var offset = isPart2 ? 10_000_000_000_000 : 0;
int? maxPresses = isPart2 ? null : 100;
var machines = input
.Split($"{Environment.NewLine}{Environment.NewLine}")
.Select(s => s.Split(Environment.NewLine))
.Select(s => Machine.From(s, maxPresses, offset))
.ToList();
var result = machines.Sum(m => m.TokenCost);
stopwatch.Stop();
Console.WriteLine($". ({stopwatch.ElapsedMilliseconds}ms)");
Console.WriteLine($"The fewest tokens to when all possible games is {result}. ({stopwatch.ElapsedMilliseconds}ms)");