I hope I understand the arrangement. Was it like in the picture?
The absolute heights are not needed, as only the change of potential energy counts. You start when the spring is unstretched, and the cart is in rest. Consider that position of both the cart and the hanging weight as reference points to their own potential energy. When you release the cart, it will move uphill by distance x_{1}, and the hanging weight will descend by the same x_{1} and the spring will be stretched also by x_{1}, till they come to rest and then start to move backwards. Find the potential energy both of the cart and weight with respect to their starting positions. Also find the elastic energy of the spring.
The cart moves downhill, and stops at point x_{2}.
Then the cart moves again upward and reaches the position x_{3}, and so on.
To get the distance follow the motion of the cart. First it moved from x=0 to x_{1}. The distance traveleld is L(1)=X_{1} Then it moved from x_{1} to x_{2} backwards. x_{2}<x_{1}. The displacement is x_{2}x_{1}. The distance travelled in the second step is x_{2}x_{1} =x_{1}x_{2}and the total distance travelled during the first and second steps is L(2)=x_{1}+x_{1}x_{2}=2x_{1}x[SUB]2.
You can continue for all steps, tracing the distance travelled and calculating energy at every points x_{i}.
ehild
