This commit is contained in:
2022-12-09 07:45:55 +01:00
parent c9a854978a
commit dd94ac5a93
3 changed files with 162 additions and 0 deletions

23
day09/ex2/main.go Normal file
View File

@@ -0,0 +1,23 @@
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))
}