Closest-pair problem: Difference between revisions
Content added Content deleted
m (BASIC 256 and BBC BASIC moved to the BASIC section.) |
(Added Easylang) |
||
Line 972: | Line 972: | ||
=={{header|Delphi}}== |
=={{header|Delphi}}== |
||
See [https://rosettacode.org/wiki/Closest-pair_problem#Pascal Pascal]. |
See [https://rosettacode.org/wiki/Closest-pair_problem#Pascal Pascal]. |
||
=={{header|EasyLang}}== |
|||
{{trans|AWK}} |
|||
<syntaxhighlight> |
|||
# bruteforce |
|||
numfmt 4 0 |
|||
x[] = [ 0.654682 0.409382 0.891663 0.716629 0.477721 0.925092 0.624291 0.211332 0.293786 0.839186 ] |
|||
y[] = [ 0.925557 0.619391 0.888594 0.996200 0.946355 0.818220 0.142924 0.221507 0.691701 0.728260 ] |
|||
n = len x[] |
|||
min = 1 / 0 |
|||
for i to n - 1 |
|||
for j = i + 1 to n |
|||
dx = x[i] - x[j] |
|||
dy = y[i] - y[j] |
|||
dsq = dx * dx + dy * dy |
|||
if dsq < min |
|||
min = dsq |
|||
mini = i |
|||
minj = j |
|||
. |
|||
. |
|||
. |
|||
print "distance between (" & x[mini] & " " & y[mini] & ") and (" & x[minj] & " " & y[minj] & ") is " & sqrt min |
|||
</syntaxhighlight> |
|||
=={{header|Elixir}}== |
=={{header|Elixir}}== |
||
<syntaxhighlight lang="elixir">defmodule Closest_pair do |
<syntaxhighlight lang="elixir">defmodule Closest_pair do |
||
Line 1,049: | Line 1,073: | ||
{0.9399398976079764, 0.020522908141823986}}}} |
{0.9399398976079764, 0.020522908141823986}}}} |
||
</pre> |
</pre> |
||
=={{header|F Sharp|F#}}== |
=={{header|F Sharp|F#}}== |
||
Brute force: |
Brute force: |