try/tsp.rb
# Calculate distance between two points in any size of dimension.
# The two points are in same dimension.
Calculate distance between two points in any size of dimension.
The two points are in same dimension.
Calculate distance between two points in any size of dimension . The two points are in same dimension .
def distance(p1, p2)
  if p1.size != p2.size
    raise "dimension of the points is not same!"
  end
  sum = 0.0
  p1.size.times do |i|
    sum += (p1[i] - p2[i])**2
  end
  return sum
end
def distance ( p1 , p2 ) if p1 . size != p2 . size raise "dimension of the points is not same!" end sum = 0.0 p1 . size . times do | i | sum += ( p1 [ i ] - p2 [ i ] ) ** 2 end return sum end
Calculate distance between two points in any size of dimension.
Calculate distance between two points in any size of dimension .
#return Math::sqrt(sum)
p1
<not_specific>
p2
<not_specific>