RaceStats.cs 342 B

1234567891011
  1. namespace Day6;
  2. public record RaceStats(int Duration, int Distance)
  3. {
  4. public int LowerBound()
  5. {
  6. var lowerBound = (-Duration + Math.Sqrt(Duration * Duration - 4 * Distance)) / (-2.0);
  7. var nextWhole = (int)Math.Ceiling(lowerBound);
  8. return nextWhole > lowerBound ? nextWhole : nextWhole + 1;
  9. }
  10. }