There are two principles involved here. They are momentum and restitution. In the equations that follow, I am taking the direction as positive, and I'm assuming that the velocities of and are and respectively, after the impact. So:
1 The momentum of the system is conserved at the impact. So (noting that the masses are all 1 kg):
2 The restitution equation is: the velocity of separation = -e times the velocity of approach.
In other words, the (velocity of velocity of ) after impact (velocity of velocity of ) before impact. So (remembering that we are taking as the positive direction):
Add (1) and (2):
and if collides with