diff --git a/day-06/internal/two/solve.go b/day-06/internal/two/solve.go index 643530b..f0c82a6 100644 --- a/day-06/internal/two/solve.go +++ b/day-06/internal/two/solve.go @@ -35,19 +35,18 @@ func Solve(buf []byte) (int, error) { p.y == 0 && p.direction == N || p.y == len(g.data)-1 && p.direction == S || p.x == len(g.data[p.y])-1 && p.direction == E) { - p = nextPoint(p) - if g.valueAt(p.x, p.y) == '#' || g.valueAt(p.x, p.y) == 'O' { - p.recalibrate() - } - _, ok := visited[p] if ok { log.Tracef("loop: \n%s\n", g.trace(visited)) isLoop <- true return } - visited[p] = struct{}{} + + p = nextPoint(p) + if g.valueAt(p.x, p.y) == '#' || g.valueAt(p.x, p.y) == 'O' { + p.recalibrate() + } } isLoop <- false }()