2022 Day 15, part 1 complete

Going home from C&C
This commit is contained in:
2022-12-15 10:57:33 -06:00
parent 194d2875a8
commit c23342023b
7 changed files with 397 additions and 11 deletions

View File

@@ -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 {

View File

@@ -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)
}