public double SolveAcceleration(double acceleration) { var myCar = new MyCar(); foreach (var otherCarPos in OtherCar.KnownPositions.Skip(1)) { var positionIfFree = myCar.ComputePositionAtTime(otherCarPos.Time, acceleration); if (positionIfFree.X >= otherCarPos.X) { myCar.KnownPositions.Add(otherCarPos); } } var myTimeToReach = myCar.ComputeTimeToReach(Distance, acceleration); var hisTimeToReach = OtherCar.ComputeTimeToReach(Distance); return(Math.Max(myTimeToReach, hisTimeToReach)); }
public double SolveAcceleration(double acceleration) { var myCar = new MyCar(); foreach (var otherCarPos in OtherCar.KnownPositions.Skip(1)) { var positionIfFree = myCar.ComputePositionAtTime(otherCarPos.Time, acceleration); if (positionIfFree.X >= otherCarPos.X) myCar.KnownPositions.Add(otherCarPos); } var myTimeToReach = myCar.ComputeTimeToReach(Distance, acceleration); var hisTimeToReach = OtherCar.ComputeTimeToReach(Distance); return Math.Max(myTimeToReach, hisTimeToReach); }