あなたは、次のような文字列として算術一連の方程式を、与えられます。
y = x + 1
5 = x + 3
10 = z + y + 2
式は、加算だけを使用して、改行で区切られています。それらの値にすべての変数のマッピングを返します。それが不可能な場合は、nullを返します。この例では、返す必要があります:
{
x: 2,
y: 3,
z: 5
}
The solution offered by Daily Coding Problem is a simpified version, and incorrect when there is no single-variable equation or there are conflicting single-variable equations.
Solving a system of linear equations is a lot more involved than that. Refer to the following for more information.
https://en.wikipedia.org/wiki/Gaussian_elimination
https://www.geeksforgeeks.org/gaussian-elimination/