package main const ( LEFT = iota // 0 RIGHT ) var directions string var steps = map[string][]string{} // one returns the number of steps to reach 'ZZZ' func one(lines []string) int { parselines(lines) num := 0 for i, step := 0, "AAA"; step != "ZZZ"; i, num = i+1, num+1 { if i == len(directions) { i = 0 } if directions[i] == 'L' { step = steps[step][LEFT] } else { step = steps[step][RIGHT] } } return num }