# Код на ruby 2.2.3p173
def distance(x1, y1, x2, y2)
return ((x1 - x2) ** 2.0 + (y1 - y2) ** 2.0) ** 0.5
end
def zadanie(points)
return 0 if points.size < 2
s = 0
for i in 1...points.size
s += distance(points[i-1][0], points[i-1][1], points[i][0], points[i][1])
end
return s
end
# Примеры применения
p zadanie([[1,1]])
p zadanie([[1,1],[2,2]])
p zadanie([[1,1],[2,1],[3,1],[4,1],[5,1],[6,1],[7,1],[8,1],[9,1]])
p zadanie([[0,1],[2,1],[3,2],[4,1],[5,1],[6,1],[7,2],[8,1],[9,1],[7,2],[8,1],[9,1]])