2022 Day 15, part 1 complete
Going home from C&C
This commit is contained in:
@@ -118,7 +118,7 @@ func (c Coordinate) String() string {
|
||||
}
|
||||
|
||||
func (c Coordinate) Distance(t Coordinate) int {
|
||||
return AbsInt(c.X-t.X) + AbsInt(c.Y-t.Y)
|
||||
return ManhattanDistance(c.X, c.Y, t.X, t.Y)
|
||||
}
|
||||
|
||||
func (c Coordinate) Equals(c2 Coordinate) bool {
|
||||
|
@@ -416,3 +416,7 @@ func Sum(l, h int) int {
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func ManhattanDistance(x1, y1, x2, y2 int) int {
|
||||
return AbsInt(x1-x2) + AbsInt(y1-y2)
|
||||
}
|
||||
|
Reference in New Issue
Block a user