aoc2024/day-10/internal/two/graph.go

32 lines
516 B
Go
Raw Permalink Normal View History

2024-12-10 21:45:16 +00:00
package two
import (
"strings"
)
type point struct {
2024-12-10 22:04:52 +00:00
x int
y int
2024-12-10 21:45:16 +00:00
}
type graph struct {
data []string
startPositions []point
}
func newGrid() *graph {
return &graph{data: make([]string, 0), startPositions: make([]point, 0)}
}
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])
}