Expected probability distribution of middle length when a rod is cut twice The question is :

A farmer makes cuts at two points selected at random on a piece of
lumber of length $l$. What is the expected value of the length of the
middle piece?

The answer is supposed to be $l/3$.
My attempt: If $X$ and $Y$ are the lengths of the cuts starting from a fixed end for the 1st & 2nd cut, the 2nd cut being made after the first, clearly $X$ is uniform on $(0,l)$. What will be the distribution of $Y$ and of $|Y-X|$? Hence I wish to find $E(|Y-X|)$.
 A: Let $X$ and $Y$ be the first and second cuts. Let $Z$ be the length of the middle cut.
Then $Z = \max(X, Y) - \min(X,Y)$.
I first calculated the CDF of $Z$
\begin{align*}
    P(Z \leq z) &= P(\max(X, Y) - \min(X,Y) \leq z)\\
    &= \frac{1}{2} P(Y - X \leq z | Y \geq X) + \frac{1}{2} P(X - Y \leq z | Y < X)
\end{align*}
We have the conditional PDF of $X$ and $Y$ given the event $\{ Y \geq X \}$ as
\begin{align*}
    f_{XY | \{ Y \geq X \}} (x, y) &= \begin{cases}
    0 & y < x\\
    2/l^2 & y \geq x
    \end{cases}
\end{align*}
where $(x, y) \in [0, l] \times [0, l]$.
Hence,
\begin{align*}
    P(Y - X \leq z | Y \geq X) &= \int \int_{\mathcal{R}} \frac{2}{l^2} dx dy =  1 - \left(\frac{l - z}{l} \right)^2,
\end{align*}
where $$\mathcal{R} = \{ (x,y) \in [0, l] \times [0,l]: x \leq y \leq x+z \}.$$
Since  $ P(Y - X \leq z | Y \geq X) =  P(X - Y \leq z | X > Y)$ by symmetry, we have
\begin{align*}
    P(Z \leq z) &=  1 - \left(\frac{l - z}{l} \right)^2
\end{align*}
Then calculate the PDF of $Z$ by differentiating and then calculate $\mathbb{E}[Z]$.
Edit: How to determine the conditional PDF of $(X,Y)$ given the event $\{X \leq Y \}$?
First note that the unconditional PDF $f_{XY}(x,y)$ of $(X,Y)$ is simply $1/l^2$ over the region $[0, l] \times [0, l]$.
The conditional PDF given any event $A$ is
\begin{align}
f_{XY|A}(x, y) &= \begin{cases}
 \frac{f_{XY}(x,y)}{P(A)} & (x, y) \in A\\
0 & \text{otherwise}
\end{cases}
\end{align}
A: Consider the unit stick length $1$. Make two marks, $x$ and $y$ randomly, both on the unit length.
Let the first cut  be at $x$. Let $f_y$ be the sum of the possible lengths of the middle piece after another cut at $y$, i.e.
$$f_y=\int_0^y (y-x) dx + \int_y^1 (x-y) dx$$
$$= \left(xy-\frac{x^2}{2}\right)\big|_0^y + \left(\frac{x^2}{2}-xy\right)\big|_y^1$$
$$=\frac{y^2}{2}+\frac{1}{2}-y+\frac{y^2}{2}$$
$$=\frac{y^2}{2}+\frac{(1-y)^2}{2}$$
The average is given by
$$\int_0^1 f_y dy=\int_0^1 \left(\frac{y^2}{2}+\frac{(1-y)^2}{2}\right) dy$$
$$= \left(\frac{y^3}{6}-\frac{(1-y)^3}{6}\right)\big|_0^1$$
$$=\frac13$$
Multiply by $l$ to get the answer.
A: Let $U=1$ if $Y>X$, $U=-1$ otherwise. Clearly $P(U=1)=P(U=-1)=1/2$.
Then $$E [| Y-X | ] = E [U(Y-X)] = E[UY]-E[UX]$$
By symmetry, $E[UX]=-E[UY]$, then
$$E [| Y-X | ] = 2 E[UY]$$
with $$E[UY]= E [ E[ UY |U]]= \frac12 E[Y|U=1]-\frac12 E[Y|U=-1]$$
Now $f_{Y|U=1}$ is a triangular , hence $E[Y|U=1]=\frac23$ and $E[Y|U=-1]=\frac13$.
Hence
$$E [| Y-X | ] = 2 \left( \frac12 \frac 23 - \frac12 \frac 13  \right) = \frac13$$
