Your question is Compute Series Parallel Resistance. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Given an array of resistor values in ohms and an array of operations describing how they are connected, compute the equivalent resistance of the circuit. Each operation is one of:
"R i" — push resistor values[i] onto the stack"S" — pop the top two resistances and replace them with their series equivalent"P" — pop the top two resistances and replace them with their parallel equivalent using 1 / (1/a + 1/b)Return the final equivalent resistance as a floating-point number. If the operations are invalid, return -1.0.
"R i" must satisfy 0 <= i < values.lengthdef equivalent_resistance(values, ops):