2025 Day 9 Complete!
This commit is contained in:
@@ -42,6 +42,18 @@ func (c *Coordinate) MoveNW() {
|
||||
c.Y--
|
||||
}
|
||||
|
||||
func (c Coordinate) AreaTo(o Coordinate) int {
|
||||
x1, x2 := c.X, o.X
|
||||
y1, y2 := c.Y, o.Y
|
||||
if x1 < x2 {
|
||||
x1, x2 = x2, x1
|
||||
}
|
||||
if y1 < y2 {
|
||||
y1, y2 = y2, y1
|
||||
}
|
||||
return ((x1 - x2) + 1) * ((y1 - y2) + 1)
|
||||
}
|
||||
|
||||
func (c Coordinate) Sub(o Coordinate) Coordinate {
|
||||
return Coordinate{
|
||||
X: c.X - o.X,
|
||||
|
||||
Reference in New Issue
Block a user