package one import ( "slices" "strings" log "github.com/sirupsen/logrus" ) type point struct { x int y int } func newPoint(x, y int) point { return point{x, y} } type graph struct { data []string } func newGraph() *graph { return &graph{} } func (g *graph) String() string { return strings.Join(g.data, "\n") } func (g *graph) isOutOfBounds(p point) bool { return p.x < 0 || p.y < 0 || p.y >= len(g.data) || p.x >= len(g.data[p.y]) } func (g *graph) valueAt(p point) rune { return rune(g.data[p.y][p.x]) } func (g *graph) debug(visited map[point]struct{}) string { log.Debugf("path for %s", string(g.valueAt(firstPointFromMap(visited)))) temp := slices.Clone(g.data) for point := range visited { temp[point.y] = replaceAtIndex(temp[point.y], 'x', point.x) } return strings.Join(temp, "\n") }