2020 Day 19 & 20 Complete
This commit is contained in:
@@ -14,6 +14,10 @@ func NewCoordinate(x, y int) *Coordinate {
|
||||
return &Coordinate{x, y}
|
||||
}
|
||||
|
||||
func (c Coordinate) Relative(t Coordinate) Coordinate {
|
||||
return Coordinate{X: c.X + t.X, Y: c.Y + t.Y}
|
||||
}
|
||||
|
||||
func (c *Coordinate) North() Coordinate {
|
||||
return Coordinate{X: c.X, Y: c.Y - 1}
|
||||
}
|
||||
|
@@ -263,6 +263,25 @@ func StringSliceContains(h []string, n string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IntSliceContains takes an int slice and an int and return true
|
||||
// if the int is in the slice
|
||||
func IntSliceContains(h []int, n int) bool {
|
||||
for _, v := range h {
|
||||
if v == n {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// AppendString returns a slice of strings that are base+group[...]
|
||||
func AppendStrings(base string, group []string) []string {
|
||||
for k, v := range group {
|
||||
group[k] = base + v
|
||||
}
|
||||
return group
|
||||
}
|
||||
|
||||
// IsPrime takes a number and return true if that number is prime
|
||||
func IsPrime(value int) bool {
|
||||
for i := 2; i <= int(math.Floor(float64(value)/2)); i++ {
|
||||
|
Reference in New Issue
Block a user