mirror of
https://github.com/onyx-and-iris/aoc2024.git
synced 2025-01-08 13:50:48 +00:00
add factory method newAntiNodeCache()
This commit is contained in:
parent
c1b8cb3f18
commit
5ed54e672b
@ -12,6 +12,10 @@ type graph struct {
|
||||
antinodes map[coords]struct{}
|
||||
}
|
||||
|
||||
func newGraph() *graph {
|
||||
return &graph{antinodes: make(map[coords]struct{})}
|
||||
}
|
||||
|
||||
func (g *graph) String() string {
|
||||
return strings.Join(g.data, "\n")
|
||||
}
|
||||
|
@ -14,8 +14,6 @@ func Solve(buf []byte) (int, error) {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
graph.antinodes = make(map[coords]struct{})
|
||||
|
||||
for i, a := range graph.antennae {
|
||||
for j, b := range graph.antennae {
|
||||
if i == j || a.identifier != b.identifier {
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
var reMatchAntennae = regexp.MustCompile(`[a-zA-Z0-9]`)
|
||||
|
||||
func parseLines(r io.Reader) (*graph, error) {
|
||||
var graph graph
|
||||
graph := newGraph()
|
||||
|
||||
var linecount int
|
||||
scanner := bufio.NewScanner(r)
|
||||
@ -30,5 +30,5 @@ func parseLines(r io.Reader) (*graph, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &graph, nil
|
||||
return graph, nil
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ type graph struct {
|
||||
}
|
||||
|
||||
func newGraph() *graph {
|
||||
return &graph{[]string{}, []antenna{}, newAntiNodeCache()}
|
||||
return &graph{antinodes: newAntiNodeCache()}
|
||||
}
|
||||
|
||||
func (g *graph) String() string {
|
||||
|
Loading…
Reference in New Issue
Block a user