2020 Day 24 Complete

I made some minor changes to helpers/coordinate... I probably need to go
back and fix several previous years/days.
This commit is contained in:
2020-12-24 09:58:15 -06:00
parent 3b5bae7948
commit 10a3ba0699
5 changed files with 701 additions and 4 deletions

View File

@@ -18,16 +18,16 @@ func (c Coordinate) Relative(t Coordinate) Coordinate {
return Coordinate{X: c.X + t.X, Y: c.Y + t.Y}
}
func (c *Coordinate) North() Coordinate {
func (c Coordinate) North() Coordinate {
return Coordinate{X: c.X, Y: c.Y - 1}
}
func (c *Coordinate) East() Coordinate {
func (c Coordinate) East() Coordinate {
return Coordinate{X: c.X + 1, Y: c.Y}
}
func (c *Coordinate) South() Coordinate {
func (c Coordinate) South() Coordinate {
return Coordinate{X: c.X, Y: c.Y + 1}
}
func (c *Coordinate) West() Coordinate {
func (c Coordinate) West() Coordinate {
return Coordinate{X: c.X - 1, Y: c.Y}
}
func (c *Coordinate) NW() Coordinate {

View File

@@ -340,3 +340,17 @@ func IsPrime(value int) bool {
}
return value > 1
}
func Min(v1, v2 int) int {
if v1 < v2 {
return v1
}
return v2
}
func Max(v1, v2 int) int {
if v1 > v2 {
return v1
}
return v2
}