All problems
Depot Assignment Nearest
Problem
Assign each customer to its nearest depot. depot_dist is a matrix where row i lists the distance from customer i to each depot.
Return the list of chosen depot indices in customer order, breaking ties by the smallest depot index.
Hint
With a single depot every customer assigns to depot 0.
Test cases
case 1
in: [[[2,5],[4,1],[3,3]]]
expected: [0,1,0]
case 2
in: [[[7],[8]]]
expected: [0,0]
case 3
in: [[[1,1],[1,1]]]
expected: [0,0]
case 4
in: [[[5,2],[6,3]]]
expected: [1,1]
Starter codePython
def assign_to_depots(depot_dist):
# Your code here
pass4 test cases · run your code against them in the editor