Here x is the displacement, ν is the speed, p is the momentum, a is the acceleration, KE is the kinetic energy, F is the force.
(Fext)system=0⟹→p1+⟹→p2=0
m1ν1=m2ν2⟹ν1ν2=m2m1
m1∫10ν1dt=m2∫10ν2dt
Where t is the time interval of motion of each block.
m1x1=m2x2⟹x1x2=m2m1
KE1KE2=P21/2m1P22/2m2=m2m1
⟹F1F2=kxkx
Where x is the deformation of the spring.
∴F1F2=1⟹m1a1m2a2=1⟹a1a2=m2m1