adventofcode/2018/day23/coord.go

19 lines
264 B
Go
Raw Normal View History

package main
type Coordinate struct {
X, Y, Z int
}
var Zero = Coordinate{X: 0, Y: 0, Z: 0}
func (c Coordinate) Distance(a Coordinate) int {
return abs(c.X-a.X) + abs(c.Y-a.Y) + abs(c.Z-a.Z)
}
func abs(v int) int {
if v < 0 {
return v * -1
}
return v
}