feat: solved day 2 part 1...part 2 is WIP

This commit is contained in:
Stevan Freeborn
2024-12-03 02:32:30 -06:00
parent 17f6c01170
commit 60b5c726cf
10 changed files with 340 additions and 1 deletions
+30
View File
@@ -0,0 +1,30 @@
using System.Diagnostics;
using RedNosedReports;
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.ReadAllLinesAsync(args[0]);
var stopwatch = new Stopwatch();
stopwatch.Start();
var reports = new PuzzleParser().Parse(input);
var numberOfSafeReports = isPart2
? reports.Count(r => r.IsSafeWithProblemDampener())
: reports.Count(r => r.IsSafe());
stopwatch.Stop();
Console.WriteLine($"The total number of safe reports is {numberOfSafeReports}. ({stopwatch.ElapsedMilliseconds}ms)");