package two import "fmt" type point struct { x int y int direction int } func (p *point) String() string { return fmt.Sprintf("X: %d Y:%d Direction: %s", p.x, p.y, []string{"N", "E", "S", "W", "Obs"}[p.direction]) } func (p *point) recalibrate() { switch p.direction { case N: p.y++ case E: p.x-- case S: p.y-- case W: p.x++ } if p.direction == W { p.direction = 0 } else { p.direction++ } } func nextPoint(current point) point { switch current.direction { case N: return point{current.x, current.y - 1, current.direction} case E: return point{current.x + 1, current.y, current.direction} case S: return point{current.x, current.y + 1, current.direction} case W: return point{current.x - 1, current.y, current.direction} default: return point{} } }