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

32 lines
516 B
Go

package one
import (
"strings"
)
type point struct {
x int
y int
}
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])
}