Squarepoint Capital interview question

implement a method to minimize the distance