bomb detonation algorithm