hackathon/question/q01/part2.go

23 lines
355 B
Go

package q01
import "strconv"
func solveP2(steps []string) (x int, y int) {
known := make(map[int]map[int]bool)
for _, step := range steps {
dir := step[0]
amt, _ := strconv.Atoi(step[1:])
x, y = move(x, y, dir, amt)
if known[x] == nil {
known[x] = make(map[int]bool)
}
if known[x][y] {
return
}
known[x][y] = true
}
return
}