Setups other learners found interesting in 1D Collision simulation. Try one, then tweak it.
Two bodies move along a line and collide. Momentum is always conserved in the collision; kinetic energy is conserved only if the collision is perfectly elastic. Set the masses, the initial velocities and the restitution, then read off the momentum and kinetic energy before and after to see which quantities survive.
Read the full theory: What is the difference between elastic and inelastic collisions? →