An ideal spring is attached to a wall, and the other end is attached to a mass $m$. The spring is initially compressed a distance $x$. After it is released, the mass collides with another mass $2m$ at a distance $x/2$ to the right of the spring equilibrium. The collision is inelastic and they slide together. How far will they slide before coming to a momentary stop?
My work
Since the collision is inelastic then mechanical energy is not conserved. And since the two-mass system has an external force, momentum is not conserved. So one has to use only mechanical principles to solve this.
We can compute the velocity of the mass at the moment of impact using simple harmonic motion, $r(t) = -x\cos\left( t\sqrt{k/m}\right)$ so that $x/2 = -x\cos \left(t^{*}\sqrt{k/m}\right)$. With this I could do an awkward solution for time and maybe continue from there.
At this point, though, I'm not perfectly clear on how to move forward. Do I just assume that momentum is conserved for a very, very short time period during the collision and use that to find the velocity of the combined mass system, then put that into another simple harmonic motion problem?