Using super flexible keyword parameters
Some design problems involve solving a simple equation for one unknown given enough known values. For example, rate, time, and distance have a simple linear relationship. We can solve for any one given the other two. Here are the three rules that we can use as an example:
- d = r × t
- r = d / t
- t = d / r
When designing electrical circuits, for example, a similar set of equations is used based on Ohm's Law. In that case, the equations tie together resistance, current, and voltage.
In some cases, we want to provide a simple, high-performance software implementation that can perform any of the three different calculations based on what's known and what's unknown. We don't want to use a general algebraic framework; we want to bundle the three solutions into a simple, efficient function.
Getting ready
We'll build a single function that can solve a Rate-Time-Distance (RTD) calculation by embodying all three solutions given any two known values. With minor variable...