Hekumok, мой вариант
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
</head>
<body>
<script>
var a = [[94,163], [14,58], [50,40], [14,103], [10,10], [74,58], [54,163], [94,103], [50,10], [74,40]];
var Lmin = 0,
n = 0,
f = [[0, 0]],
N = a.length;
for (var i = 0; i < N; i++) {
var c = a[0][0] - f[0][0],
d = a[0][1] - f[0][1],
temp = Math.sqrt(c * c + d * d);
for (var j = 1; j < a.length; j++) {
c = a[j][0] - f[0][0],
d = a[j][1] - f[0][1];
if (Math.sqrt(c * c + d * d) < temp) {
temp = Math.sqrt(c * c + d * d);
n = j
}
}
document.write(f + "<br>" + temp + "<br>")
Lmin += temp
f = a.splice(n, 1);
n = 0;
}
document.write(f + "<br>" + Math.round(Lmin))
</script>
</body>
</html>