mirror of
https://github.com/onyx-and-iris/aoc2024.git
synced 2025-01-10 14:50:46 +00:00
33 lines
551 B
Go
33 lines
551 B
Go
|
package one
|
||
|
|
||
|
func neighbours(p node) [3]node {
|
||
|
switch p.direction {
|
||
|
case N:
|
||
|
return [3]node{
|
||
|
newNode(p.x, p.y-1, N),
|
||
|
newNode(p.x-1, p.y, W),
|
||
|
newNode(p.x+1, p.y, E),
|
||
|
}
|
||
|
case E:
|
||
|
return [3]node{
|
||
|
newNode(p.x+1, p.y, E),
|
||
|
newNode(p.x, p.y-1, N),
|
||
|
newNode(p.x, p.y+1, S),
|
||
|
}
|
||
|
case S:
|
||
|
return [3]node{
|
||
|
newNode(p.x, p.y+1, S),
|
||
|
newNode(p.x-1, p.y, W),
|
||
|
newNode(p.x+1, p.y, E),
|
||
|
}
|
||
|
case W:
|
||
|
return [3]node{
|
||
|
newNode(p.x-1, p.y, W),
|
||
|
newNode(p.x, p.y+1, S),
|
||
|
newNode(p.x, p.y-1, N),
|
||
|
}
|
||
|
default:
|
||
|
return [3]node{}
|
||
|
}
|
||
|
}
|