The sum of the squares of the legs is equal to the square of the hypotenuse.
I think this function will work. It returns the index with the smallest value.
function min(array)
local l = length(array);
local index = {};
local r;
for i1, n1 in array do
index[i1] = 0;
for i2, n2 in array do
if n1 < n2 then
index[i1] = index[i1] + 1;
end;
end;
end;
for i, c in index do
if c == l - 1 then
r = i;
end;
end;
return r;
end;Assuming that the index of the argument passed to the function is the name of a city, and the value is the distance. That is, it will return the name of the nearest city (from those in the array).
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога
Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4