2018 Day 23*
Had to find someone else's python solution to get an answer. Need to pull it apart and figure out what's wrong with my solution.
This commit is contained in:
18
2018/day23/coord.go
Normal file
18
2018/day23/coord.go
Normal file
@@ -0,0 +1,18 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user