type Point struct {
x int
y int
}
var points = []Point{{4, 5}, {7, 1}, {2, 9}}
func distance(a, b Point) float64 {
dx := float64(a.x - b.x)
dy := float64(a.y - b.y)
return math.Sqrt(dx*dx + dy*dy)
}
func main() {
origin := Point{0, 0}
ans := math.MaxFloat64
for _, point := range points {
dist := distance(origin, point)
if dist < ans {
ans = dist
}
}
fmt.Println(ans)
}