Files
advent-of-code-2022/day09/ex2/main.go
2022-12-09 07:45:55 +01:00

24 lines
421 B
Go

package main
import (
"bufio"
"fmt"
"os"
"aoc2022/day09/common"
)
func main() {
movements := common.Parse(*bufio.NewScanner(os.Stdin))
grid := common.NewGrid(10)
visited := make(map[common.Position]struct{})
for _, movement := range movements {
tailVisited := grid.Move(movement)
for position := range tailVisited {
visited[position] = struct{}{}
}
}
fmt.Println(len(visited))
}