Your question is Relative Velocity from Coordinates. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Given two vehicles moving in a 2D plane, each represented by two consecutive positions: (x1, y1) at time t1 and (x2, y2) at time t2, compute the relative velocity vector of the merging vehicle with respect to the ego vehicle. Return [rvx, rvy, speed], where rvx and rvy are the relative velocity components and speed is the magnitude of that relative velocity.
def relative_velocity(ego, merge, dt):