This is the code used to solve the EQUATIONS_SOLVER CHALLENGE
from CodeFights.
You're given a string containing a simple linear equation. Your task is to find the value of x
.
The equation contains only operators +
, -
, *
, =
, x
(only once) and digits. It is guaranteed that all sub-results are integers.
Examples:
-
equations_solver("2x+4=20") = 8
-
equations_solver("5*2+x*2=40") = 15
-
[input] string e
- The string that contains the expression.
-
[output] integer
- The value of x.