adventofcode/2018/day22/coord.go

20 lines
258 B
Go
Raw Permalink Normal View History

2019-11-07 17:53:26 +00:00
package main
type coord struct {
x, y int
}
func (c coord) neighbors() []coord {
n := []coord{
{c.x + 1, c.y},
{c.x, c.y + 1},
}
if c.x > 0 {
n = append(n, coord{c.x - 1, c.y})
}
if c.y > 0 {
n = append(n, coord{c.x, c.y - 1})
}
return n
}