Codevita Round 2

Please anyone help me with the Collision problem asked there.