2025 Day 9 Complete!

This commit is contained in:
2025-12-09 09:59:06 -06:00
parent d10e9f9a9a
commit a980fd721b
7 changed files with 790 additions and 0 deletions

View File

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

View File

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