package one import ( "github.com/onyx-and-iris/aoc2024/day-12/internal/queue" ) func explore(start point, graph *graph) path { queue := queue.New[point]() queue.Enqueue(start) visited := make(map[point]struct{}) var perimeter int for !queue.IsEmpty() { current := queue.Dequeue() _, ok := visited[current] if ok { continue } visited[current] = struct{}{} for _, n := range neighbours(current) { if graph.isOutOfBounds(n) { perimeter++ continue } if graph.valueAt(n) != graph.valueAt(current) { perimeter++ continue } queue.Enqueue(n) } } return path{visited, perimeter} }