When the foot of a staircase is $5$ meters from the base of a wall, it protrudes $10$ meters above the wall; and if it is $9$ meters from the base, it stands $8$ meters.
Find the height of the wall.
Using the Pythagorean theorem for the two situations I have
$$\begin{cases}(10-x)^2=5^2+y^2\\(8-x)^2=9^2+y^2,\end{cases}$$ where $x$ is the hypotenuse and $y$ is the height of the wall.
Solving that system of equations I have that $x=23$ and $y=\pm12$, but since a height is always positive, the solution is $\boxed{12~\text{meters}}$.
Is it correct?
I am not sure of the $x$ value because first it has a value but then it has another, so maybe we have to use $x_1$ and $x_2$, but then we have $3$ equations with $2$ variables, so it is not possible.
Thanks!

Let $z$ be the length of the ladders, then
$$(z-10)^2=5^2+y^2$$
$$(z-8)^2=9^2+y^2$$
subtracting the two equations, we have
$$-2(2z-18) = (5-9)(5+9)$$
$$4(z-9) = (9-5)(5+9)=4(14)$$
$$z=9+14=23$$
$$(23-10)^2-5^2=y^2$$
$$y^2=13^2-5^2=12^2$$
Hence $y=12$.
Note my definition of $z$ is not the hypothenus but the length of ladder.