We've had a lot of challenges on differentiation and integration, but none on just solving related rates problems. So in this challenge, you will get a bunch of derivatives (They will be numeric, not in terms of any variables) and have to find another derivative.
The input will come in a newline separated list of equations, in the form dx/dt = 4
. There can be decimals and negatives.
The input will end with one differential, the one you will have to find. You can assume there will always be enough information to find it, butt there may also be excess information.
You may also have to consider the derivative of the inverse function, e.g. if you have dy/dx = 3
, you also know that dx/dy = 1/3
.
Your output will be in the form dy/dt = 6
. All the whitespace, etc. has to be the same. Assume all variables are always one letter (They can be uppercase, and they can be d
).
This is code-golf, so shortest code in bytes wins!
Test Cases
dy/dx = 4
dx/dt = 5
dy/dt
answer: dy/dt = 20
dy/dx = -3
dt/dx = 3
dy/dt
answer: dy/dt = -1
dA/dt = 4
dA/dC = 2
dC/dr = 6.28
dr/dt
answer: dr/dt = 0.3184713375796178
dx/dy = 7
dx/dt = 0
dy/dt
answer: dy/dt = 0
d_/d_
as a ratio and that makes me sad \$\endgroup\$