I have two lists:
a = [35, 400, 200]
b = [100, 32]
I want to match each value in ‘b’ with the closest value in ‘a’. Each value in ‘b’ can have at most one match. The final list contains values that are in list ’a’. So, in this case 35 is closest to 32 and 200 is closest to 100. Therefore, list that I want to get is
c = [35, 200]
I am able to solve this with a for loop, however I am looking for a vectorized solution.