I am creating a program which needs to do the following:
I have equations like the following and based on the input I get I should able to calculate the values of $x$, $y$ and $z$
$$x = a + b$$ $$y = x + c$$ $$z = x + y$$
When I get input in the order of $a$, $b$ and $c$ then I can evaluate the expression in the following order
find if $a$ belongs to any expression, if it is find any associated variables available in the input and in this $b$ is available in the input then calculate $x$. Check and see if $x$ is used in any other formula and in this case it is used to calculate $y$, so try to calculate the value of $y$. It requires $c$ use that and calculate $y$. Repeat the same for $y$ and calculate $z$. All works out.
Now if the input comes in different order, based on the formulas that I know before hand, I can sort the input and calculate the formulas properly.
Can any one think of better approach to this problem than the two options I suggested here?
** I can not normalize the equation since each value on left hand side need to be persisted for other purposes **