2
* @param {number[][]} positions5
var getMinDistSum = function (positions) {7
identify the vertical range and horizontal range9
start from the center of positions11
test the 4 direction with a certain step12
if any distance is closer, choose it as the new candidate13
if all 4 are further, reduce the step18
for (const [x, y] of positions) {23
let n = positions.length;34
while (step >= 10 ** -5) {35
const dist = calcDist(x, y);37
for (const [xDiff, yDiff] of dirs) {38
const newX = x + xDiff * step;39
const newY = y + yDiff * step;40
const newDist = calcDist(newX, newY);42
// console.log(x, y, newDist, dist);56
return calcDist(x, y);58
function calcDist(x, y) {60
for (const [posX, posY] of positions) {61
dist += Math.sqrt((x - posX) ** 2 + (y - posY) ** 2);