aoc2024/day-06/internal/one/graph.go
onyx-and-iris 08706ecc11 make use of graph factory function.
move isLoop logic into guard clause.
2024-12-06 22:23:01 +00:00

31 lines
500 B
Go

package one
import (
"strings"
"github.com/onyx-and-iris/aoc2024/day-06/internal/util"
)
type graph struct {
startPoint point
data []string
}
func newGraph() *graph {
return &graph{}
}
func (g *graph) String() string {
return strings.Join(g.data, "\n")
}
func (g *graph) debug(visited map[coords]struct{}) string {
for loc := range visited {
if !(rune(g.data[loc.Y][loc.X]) == 'O') {
g.data[loc.Y] = util.ReplaceAtIndex(g.data[loc.Y], '+', loc.X)
}
}
return g.String()
}