fastest map version

This commit is contained in:
David 2021-12-05 14:31:28 -05:00
parent c5dbac0e9c
commit b4db9ef306

View File

@ -42,12 +42,12 @@ type point struct {
}
type grid struct {
m map[point]int
m map[int]int
}
func (g *grid) AddLine(start, end point, includeHorizontal bool) {
for _, p := range LineFromPoints(start, end, includeHorizontal) {
g.m[p]++
g.m[p.x+p.y*1000]++
}
}
@ -109,7 +109,7 @@ func partOne() {
scanner := makeScanner(false)
grid := &grid{
m: map[point]int{},
m: make(map[int]int, 1000),
}
for scanner.Scan() {
line := scanner.Text()
@ -129,7 +129,7 @@ func partTwo() {
scanner := makeScanner(false)
grid := &grid{
m: map[point]int{},
m: make(map[int]int, 1000),
}
for scanner.Scan() {
line := scanner.Text()