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,
|
||||
|
||||
@@ -404,6 +404,20 @@ func SliceMin(sl []int) int {
|
||||
}
|
||||
}
|
||||
|
||||
func SetDec(v1, v2 int) (int, int) {
|
||||
if v1 < v2 {
|
||||
return v2, v1
|
||||
}
|
||||
return v1, v2
|
||||
}
|
||||
|
||||
func SetInc(v1, v2 int) (int, int) {
|
||||
if v1 > v2 {
|
||||
return v2, v1
|
||||
}
|
||||
return v1, v2
|
||||
}
|
||||
|
||||
func Min(v1, v2 int, vrest ...int) int {
|
||||
min := v2
|
||||
if v1 < v2 {
|
||||
|
||||
Reference in New Issue
Block a user