Day 9
This commit is contained in:
23
day09/ex1/main.go
Normal file
23
day09/ex1/main.go
Normal 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(2)
|
||||
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))
|
||||
}
|
||||
Reference in New Issue
Block a user