The total momentum of the system remains unchanged during the impact. This yields the velocity ¯v of the wagons after the collision :
We assume that the block stays at rest. Then we can write down the equilibrium condition
The force of static friction H and the normal force N have to satisfy the condition of static friction:
H ≤ µ0N → F ≤ µ0m3g .
With
F = kx → x ≤ µ0m3g/k
we obtain the maximum compression of the spring:
xmax = µ0m3g/k
Now we apply the Conservation of Energy Law to determine v1max: