Collisions.
A toy for two-body collisions. Two balls on a frictionless track meet with whatever mass and velocity you give them; the coefficient of restitution slider runs from e = 0 (perfectly inelastic — they stick) through partially elastic to e = 1 (perfectly elastic, kinetic energy fully preserved). Momentum is always conserved; how much kinetic energy stays around is the part that changes.
No walls. Add one to bounce balls off it; walls share the same coefficient of restitution as ball-on-ball collisions.
What you're looking at.
Two laws govern this entire widget. First, conservation of momentum: the total p = m₁v₁ + m₂v₂ before the collision equals the total after. That's true regardless of how bouncy the collision is — it falls straight out of Newton's third law. Second, the coefficient of restitution: e = −(v₁′ − v₂′) / (v₁ − v₂), which says the relative speed of separation is some fraction e of the relative speed of approach. Together those two equations give you both post-collision velocities from the inputs.
Kinetic energy is the part that's not guaranteed. Only at e = 1 does it survive the collision intact; at any lower e some of it leaks out as heat, sound, or permanent deformation. At e = 0 the maximum possible amount is lost — the two objects emerge with the same velocity and the only KE left is the kinetic energy of the combined center-of-mass motion. Real-world materials sit somewhere between: superballs around 0.9, tennis balls on hard ground around 0.7, a clay slug into a wall around 0.05.
Try the same-mass elastic case (m₁ = m₂, e = 1): they swap velocities exactly. Now drop e to 0 with everything else the same and watch them merge into a single moving blob — that's a Newton's-cradle collision turned into a kissing-Plasticine collision.