diff --git a/AdventOfCode/Day06.cs b/AdventOfCode/Day06.cs index 1a3ca2e..a23001e 100644 --- a/AdventOfCode/Day06.cs +++ b/AdventOfCode/Day06.cs @@ -38,7 +38,14 @@ private long GetWaysToWin(Race race) for (long i = 0; i < race.Time; ++i) { long distance = (race.Time - i) * i; - waysToWin += distance > race.Distance ? 1 : 0; + if (distance > race.Distance) + { + waysToWin++; + } + else if (waysToWin > 0) + { + break; + } } return waysToWin; }