How to find the compression of a spring attached to an object I am having some trouble figuring out the equation needed to solve this problem.

A 3.0-kg block slides along a frictionless tabletop at 8.0 m/s toward
  a second block (at rest) of mass 4.5 kg. A coil spring, which obeys
  Hooke's law and has spring constant k = 830N/m , is attached to the
  second block in such a way that it will be compressed when struck by
  the moving block.


Part A
What will be the maximum compression of the spring?

Part B
What will be the final velocities of the blocks after the collision?

From what I understand, in order to answer Part A I need to find $x$ (the compression of the coil) when the velocity of object 1 is the same as the velocity of object 2. However, what confuses me is trying to figure out how the force of the smaller mass will accelerate the larger.
 A: You can solve part two first(simply because it is easier). The surface is frictionless and in absence of any dissipative effects, the net energy is conserved. This means setting $v_a$ to be the velocity of $3kg$ block, and $v_b$ to be the velocity of $4.5kg$ block before collision and their final velocities are $v_a'$ and $v_b'$
$$\frac12 3 v_a^2=\frac12 3 v_a'^2+\frac12 4.5 v_b'^2$$
Next use conservation of momentum. $$3v_a=4.5v_b'+3v_a'$$ This will give you a set of equations to solve for $v_a'$ and $v_b'$.(Mark this, the $v_a$ and $v_b$ we used in momentum conservation are vectors, that is, can be both positive and negative-indicating reverse direction).  
For part one, the maximum compression will be when both the blocks will be in contact and hence performing simple harmonic oscillations. The velocity of the centre of mass of the two blocks will be given by $\frac{3v_a+4.5(0)}{3+4.5}$ which is $3.2ms^{-1}$. Therefore, the energy of the harmonic vibration (in the centre of mass frame, or the energy above the translational kinetic energy of COM) will be given by $$E_{vib}=\frac12 3v_a^2-\frac12 M_{net}v_{com}^2$$.It is this energy which will be the energy of the harmonic vibration, and all the energy in the COM frame. 
This evaluates to $57.6J$(check the calculations once again, I did this mentally and hence is very probably wrong). This energy($E_{vib}$) at maximum compression, is entirely stored in the potential energy of the spring. Hence $$E_{vib}=\frac12 k x_{max}^2$$.
 This will give you the answer to part one.  
NOTE. To understand $E_{vib}$ more clearly, consider the time when the spring has maximum compression. Here, both the blocks are stationary in the COM frame and are moving with $v_{com}$ in the observer frame (frame of the question). This means that whatever the energy difference between the original kinetic energy of block 1 and the net kinetic energy of this system at maximum compression (both blocks moving with $v_{com}$ is the energy stored in the spring.
A: Break it in to steps to figure out your doubt:


*

*Energy introduced by smaller mass of 3Kg
$\frac{1}{2}mv^{2}=0.5\times 3\times 64=96J$

*Energy transfered to spring (completely)
$\frac{1}{2}kx^{2}=0.5\times 830\times x^2=96J$
$x=\sqrt{0.231}=0.480$m

*Now, for the second part, the spring distributes this energy to both masses obeying momentum conservation principle.
$m_{1}u_{1}+m_{2}u_{2}=m_{1}v_{1}+m_{2}v_{2}$
Since the blocks stopped moving at the very moment the complete energy transfer occurred,
$0+0=m_{1}v_{1}+m_{2}v_{2}$
$\frac{v_{1}}{v_{2}}=\frac{-m_{2}}{m_{1}}=\frac{-4.5}{3}$

*Finally, energy must be conserved
$\frac{m_{1}u_{1}^{2}}{2}=\frac{m_{1}v_{1}^{2}}{2}+\frac{m_{2}v_{2}^{2}}{2}$
$3v_{1}^2=192-4.5v_2^2$

*Solving equations from 3 and 4, we get,
$v_2=17.066\ ms^{-1}$
$v_1=-25.600\ ms^{-1}$
