From a0961bb9966cbc108a858b4b467c9b766f18e310 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Wed, 6 Dec 2023 20:29:56 -0600 Subject: [PATCH] fix: dry up --- 06/WaitForIt/Program.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/06/WaitForIt/Program.cs b/06/WaitForIt/Program.cs index c6c8015..e7fcf86 100644 --- a/06/WaitForIt/Program.cs +++ b/06/WaitForIt/Program.cs @@ -18,8 +18,9 @@ public class Program var parser = new PuzzleParser(); var input = await File.ReadAllLinesAsync(args[0]); + var isPart2 = args.Length > 1 && args[1] == "part2"; - long result = args.Length > 1 && args[1] == "part2" + long result = isPart2 ? parser .ParseRace(input) .CalculateNumberOfWaysToWin() @@ -27,7 +28,14 @@ public class Program .Select(r => r.CalculateNumberOfWaysToWin()) .Aggregate((long)1, (acc, curr) => acc * curr); - Console.WriteLine($"The product of the margin of errors is {result}."); + if (isPart2) + { + Console.WriteLine($"The number of ways to win is {result}."); + } + else + { + Console.WriteLine($"The total number of ways to win is {result}."); + } return (int)result; }