2018 Day 22 Complete
This commit is contained in:
19
2018/day22/coord.go
Normal file
19
2018/day22/coord.go
Normal file
@@ -0,0 +1,19 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user