Solving equations for distance or time