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

33 lines
693 B
Go
Raw Normal View History

2024-12-08 19:55:23 +00:00
package one
import (
"strings"
"github.com/onyx-and-iris/aoc2024/day-08/internal/util"
)
type graph struct {
data []string
antennae []antenna
antinodes map[coords]struct{}
}
func (g *graph) String() string {
return strings.Join(g.data, "\n")
}
func (g *graph) isOutOfBounds(c coords) bool {
return c.x < 0 || c.y < 0 || c.y >= len(g.data) || c.x >= len(g.data[0])
}
func (g *graph) debug() string {
for _, antenna := range g.antennae {
g.data[antenna.y] = util.ReplaceAtIndex(g.data[antenna.y], antenna.identifier, antenna.x)
}
for antinode := range g.antinodes {
g.data[antinode.y] = util.ReplaceAtIndex(g.data[antinode.y], '#', antinode.x)
}
return g.String()
}