Is there something about this problem I'm missing? This seems like it's just a math problem, is there some trick I'm missing that makes it faster? Or not lose precision? Or am I missing an edge case some how?
anyways, here's a javascript solution.
constg=9.81;// gravity in m/sconstk=3600/1000;// conversion coefficient: m/s to km/hrconstdist=(v,mu,t=1)=>{v=v/k;returnv*t+v*v/(mu*2*g);}constspeed=(d,mu,t=1)=>{returnk*(Math.sqrt(g*mu*(2*d+g*t*t*mu))-g*t*mu);}console.log(dist(144,0.3))// 311.83146449201496console.log(dist(92,0.5))// 92.12909477605365console.log(speed(159,0.8))// 153.79671564846308console.log(speed(153,0.7))// 142.14404997566152
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Is there something about this problem I'm missing? This seems like it's just a math problem, is there some trick I'm missing that makes it faster? Or not lose precision? Or am I missing an edge case some how?
anyways, here's a javascript solution.