From b649a28c96ad03947843aa4add8a0c20f8066c74 Mon Sep 17 00:00:00 2001 From: C4 Patino Date: Fri, 20 Dec 2024 00:49:50 -0600 Subject: [PATCH] Finished day 20 --- 2024/cmd/root.go | 2 + 2024/day20/day20.go | 192 +++++++++++++++++++++++++++++++++++++++ 2024/day20/day20_test.go | 34 +++++++ 2024/day20/input.txt | 143 +++++++++++++++++++++++++++++ 2024/day20/test.txt | 17 ++++ 5 files changed, 388 insertions(+) create mode 100755 2024/day20/day20.go create mode 100755 2024/day20/day20_test.go create mode 100755 2024/day20/input.txt create mode 100755 2024/day20/test.txt diff --git a/2024/cmd/root.go b/2024/cmd/root.go index fdb1667..d6133ac 100644 --- a/2024/cmd/root.go +++ b/2024/cmd/root.go @@ -28,6 +28,7 @@ import ( "cpatino.com/advent-of-code/2024/day17" "cpatino.com/advent-of-code/2024/day18" "cpatino.com/advent-of-code/2024/day19" + "cpatino.com/advent-of-code/2024/day20" ) var days = map[int]func(string) (interface{}, interface{}){ @@ -50,6 +51,7 @@ var days = map[int]func(string) (interface{}, interface{}){ 17: day17.Run, 18: day18.Run, 19: day19.Run, + 20: day20.Run, } var rootCmd = &cobra.Command{ diff --git a/2024/day20/day20.go b/2024/day20/day20.go new file mode 100755 index 0000000..4704bf9 --- /dev/null +++ b/2024/day20/day20.go @@ -0,0 +1,192 @@ +package day20 + +import ( + "bufio" + "container/heap" + "image" + "math" + "os" + "strconv" +) + +type Direction int +type Cheat struct { + start image.Point + end image.Point +} + +const ( + NORTH Direction = iota + EAST + SOUTH + WEST +) + +var transformations = map[Direction]image.Point{ + NORTH: image.Point{X: 0, Y: -1}, EAST: image.Point{X: 1, Y: 0}, + SOUTH: image.Point{X: 0, Y: 1}, WEST: image.Point{X: -1, Y: 0}, +} + +type PriorityQueue struct { + Items []image.Point + Scores map[image.Point]int + Heuristics map[image.Point]int +} + +func (pq PriorityQueue) Len() int { return len(pq.Items) } +func (pq PriorityQueue) Less(i, j int) bool { + return pq.Heuristics[pq.Items[i]] < pq.Heuristics[pq.Items[j]] +} +func (pq PriorityQueue) Swap(i, j int) { pq.Items[i], pq.Items[j] = pq.Items[j], pq.Items[i] } +func (pq *PriorityQueue) Push(x interface{}) { pq.Items = append(pq.Items, x.(image.Point)) } +func (pq *PriorityQueue) Pop() interface{} { + n := len(pq.Items) + item := pq.Items[n-1] + pq.Items = pq.Items[:n-1] + return item +} + +func (pq *PriorityQueue) Add(point image.Point) { heap.Push(pq, point) } +func (pq *PriorityQueue) Remove() image.Point { return heap.Pop(pq).(image.Point) } + +func manhattanDistance(a, b image.Point) int { + return int(math.Abs(float64(a.X-b.X)) + math.Abs(float64(a.Y-b.Y))) +} + +func aStar(grid map[image.Point]bool, initial, end image.Point, rows, cols int) map[image.Point]int { + bounds := image.Rect(0, 0, cols+1, rows+1) + pq := &PriorityQueue{[]image.Point{}, map[image.Point]int{}, map[image.Point]int{}} + heap.Init(pq) + + visited := make(map[image.Point]bool) + + pq.Scores[initial] = 0 + pq.Heuristics[initial] = 0 + manhattanDistance(initial, end) + pq.Push(initial) + + for pq.Len() > 0 { + current := pq.Remove() + + visited[current] = true + + if current == end { + return pq.Scores + } + + for _, direction := range []Direction{NORTH, EAST, SOUTH, WEST} { + next := current.Add(transformations[direction]) + if !next.In(bounds) || grid[next] { + continue + } + + newScore := pq.Scores[current] + 1 + if existingScore, exists := pq.Scores[next]; !exists || newScore < existingScore { + pq.Scores[next] = newScore + pq.Heuristics[next] = newScore + manhattanDistance(next, end) + heap.Push(pq, next) + } + } + } + + return pq.Scores +} + +func cheat(results map[image.Point]int, maxDistance int) map[Cheat]int { + skips := map[Cheat]int{} + + for start, startScore := range results { + for end, endScore := range results { + distance := manhattanDistance(start, end) + if distance > maxDistance { + continue + } + + improvement := endScore - startScore - distance + if improvement <= 0 { + continue + } + + if score, exists := skips[Cheat{start, end}]; !exists || improvement < score { + skips[Cheat{start, end}] = improvement + } + } + } + + return skips +} + +func Part1(grid map[image.Point]bool, initial, target image.Point, rows, cols, threshold int) int { + results := aStar(grid, initial, target, rows, cols) + + skips := cheat(results, 2) + + count := 0 + for _, improvement := range skips { + if improvement >= threshold { + count += 1 + } + } + + return count +} + +func Part2(grid map[image.Point]bool, initial, target image.Point, rows, cols, threshold int) int { + results := aStar(grid, initial, target, rows, cols) + + skips := cheat(results, 20) + + count := 0 + for _, improvement := range skips { + if improvement >= threshold { + count += 1 + } + } + + return count +} + +func Run(filename string) (interface{}, interface{}) { + file, err := os.Open(filename) + if err != nil { + panic(err) + } + defer file.Close() + + grid := make(map[image.Point]bool) + var start, end image.Point + + scanner := bufio.NewScanner(file) + rows, cols := 0, 0 + + for scanner.Scan() { + if scanner.Text() == "" { + scanner.Scan() + break + } + + cols = len(scanner.Text()) + for x, char := range scanner.Text() { + switch char { + case 'S': + start = image.Point{X: x, Y: rows} + case 'E': + end = image.Point{X: x, Y: rows} + case '#': + grid[image.Point{X: x, Y: rows}] = true + } + } + + rows += 1 + } + + threshold, _ := strconv.Atoi(scanner.Text()) + + if err := scanner.Err(); err != nil { + panic(err) + } + + part1 := Part1(grid, start, end, rows, cols, threshold) + part2 := Part2(grid, start, end, rows, cols, threshold) + + return part1, part2 +} diff --git a/2024/day20/day20_test.go b/2024/day20/day20_test.go new file mode 100755 index 0000000..ad5c03b --- /dev/null +++ b/2024/day20/day20_test.go @@ -0,0 +1,34 @@ +package day20 + +import ( + "os" + "testing" +) + +type TestCase struct { + FileName string + Part1 interface{} + Part2 interface{} +} + +func TestDay20(t *testing.T) { + tests := []TestCase{ + {"test.txt", 44, 3081}, + {"input.txt", 1286, 989316}, + } + + for _, test := range tests { + if _, err := os.Stat(test.FileName); os.IsNotExist(err) { + t.Fatalf("test file does not exist: %v", test.FileName) + } + + part1, part2 := Run(test.FileName) + if test.Part1 != nil && part1 != test.Part1 { + t.Fatalf("%s: unexpected part1:\nwant:\t%v\ngot:\t%v", test.FileName, test.Part1, part1) + } + + if test.Part2 != nil && part2 != test.Part2 { + t.Fatalf("%s: unexpected part2:\nwant:\t%v\ngot:\t%v", test.FileName, test.Part2, part2) + } + } +} diff --git a/2024/day20/input.txt b/2024/day20/input.txt new file mode 100755 index 0000000..a70ce40 --- /dev/null +++ b/2024/day20/input.txt @@ -0,0 +1,143 @@ +############################################################################################################################################# +###...#.....#...###...#...###...###.....#...............#...###...#...###.......#...#...........#...#.....#.....#...#...#.....#.......###...# +###.#.#.###.#.#.###.#.#.#.###.#.###.###.#.#############.#.#.###.#.#.#.###.#####.#.#.#.#########.#.#.#.###.#.###.#.#.#.#.#.###.#.#####.###.#.# +#...#...#...#.#.#...#...#.#...#...#.#...#.........#...#.#.#.....#...#.#...#.....#.#.#.....#.....#.#.#.#...#.#...#.#.#.#.#...#...#.....#...#.# +#.#######.###.#.#.#######.#.#####.#.#.###########.#.#.#.#.###########.#.###.#####.#.#####.#.#####.#.#.#.###.#.###.#.#.#.###.#####.#####.###.# +#.......#...#.#.#.#.......#.....#.#.#.......#...#...#.#...#.....#...#.#.#...###...#...#...#...#...#.#.#.#...#...#.#.#.#.###...#...#...#...#.# +#######.###.#.#.#.#.###########.#.#.#######.#.#.#####.#####.###.#.#.#.#.#.#####.#####.#.#####.#.###.#.#.#.#####.#.#.#.#.#####.#.###.#.###.#.# +###...#...#...#...#.....###...#.#...#.......#.#.#...#.....#.###...#.#.#.#.....#.....#.#...#...#...#...#.#.#...#.#.#.#.#...#...#.###.#.#...#.# +###.#.###.#############.###.#.#.#####.#######.#.#.#.#####.#.#######.#.#.#####.#####.#.###.#.#####.#####.#.#.#.#.#.#.#.###.#.###.###.#.#.###.# +#...#.###...........#...#...#.#.#...#.....#...#...#.#...#...#...#...#.#.#.....#.....#.#...#.....#.#.....#...#.#...#.#.#...#...#...#.#.#.#...# +#.###.#############.#.###.###.#.#.#.#####.#.#######.#.#.#####.#.#.###.#.#.#####.#####.#.#######.#.#.#########.#####.#.#.#####.###.#.#.#.#.### +#.#...#...###.......#...#.#...#.#.#.#.....#.....#...#.#.###...#...#...#.#.#...#.....#.#...#.....#.#.......#...#...#...#.....#...#.#.#.#.#...# +#.#.###.#.###.#########.#.#.###.#.#.#.#########.#.###.#.###.#######.###.#.#.#.#####.#.###.#.#####.#######.#.###.#.#########.###.#.#.#.#.###.# +#.#.....#...#.........#.#.#.###.#.#...#.......#.#...#.#...#.......#.....#.#.#.#...#.#.#...#.....#.#.......#.....#.#.........#...#...#.#...#.# +#.#########.#########.#.#.#.###.#.#####.#####.#.###.#.###.#######.#######.#.#.#.#.#.#.#.#######.#.#.#############.#.#########.#######.###.#.# +#.......#...#...#...#.#.#.#.#...#.#...#.....#.#.#...#...#...#...#...#.....#.#.#.#.#.#.#.#.......#.#.#...###...#...#.......###...#...#.....#.# +#######.#.###.#.#.#.#.#.#.#.#.###.#.#.#####.#.#.#.#####.###.#.#.###.#.#####.#.#.#.#.#.#.#.#######.#.#.#.###.#.#.#########.#####.#.#.#######.# +###...#.#.#...#.#.#.#.#.#.#.#...#...#...#...#.#.#.#...#...#...#.....#.#...#.#.#.#.#.#...#.#.......#...#...#.#.#...#...#...#...#.#.#.....#...# +###.#.#.#.#.###.#.#.#.#.#.#.###.#######.#.###.#.#.#.#.###.###########.#.#.#.#.#.#.#.#####.#.#############.#.#.###.#.#.#.###.#.#.#.#####.#.### +#...#.#.#.#...#.#.#...#...#.#...#.......#.#...#.#.#.#...#.#...#.....#...#.#.#...#.#.#.....#.#...........#.#.#.....#.#...#...#.#.#.....#...### +#.###.#.#.###.#.#.#########.#.###.#######.#.###.#.#.###.#.#.#.#.###.#####.#.#####.#.#.#####.#.#########.#.#.#######.#####.###.#.#####.####### +#...#.#.#.....#.#.........#.#...#.###.....#...#.#.#.#...#...#...###...#...#.....#...#...#...#.......#...#.#.......#...###...#.#.#.....#...### +###.#.#.#######.#########.#.###.#.###.#######.#.#.#.#.###############.#.#######.#######.#.#########.#.###.#######.###.#####.#.#.#.#####.#.### +#...#...#.....#.#...#...#.#.###.#...#...#.....#.#.#.#.....###...#...#.#...#.....#.......#...#.......#.....#...#...#...#...#.#...#.......#...# +#.#######.###.#.#.#.#.#.#.#.###.###.###.#.#####.#.#.#####.###.#.#.#.#.###.#.#####.#########.#.#############.#.#.###.###.#.#.###############.# +#...#.....###.#...#...#...#.....#...#...#...#...#...#.....#...#.#.#.#.#...#.....#...#...#...#.#...#...###...#.#...#...#.#.#.....#...........# +###.#.#######.###################.###.#####.#.#######.#####.###.#.#.#.#.#######.###.#.#.#.###.#.#.#.#.###.###.###.###.#.#.#####.#.########### +###...#.......#.........#...#...#...#.#.....#...#.....#...#...#...#.#.#...#.....#...#.#.#.#...#.#.#.#...#...#.....#...#.#...#...#...#...#...# +#######.#######.#######.#.#.#.#.###.#.#.#######.#.#####.#.###.#####.#.###.#.#####.###.#.#.#.###.#.#.###.###.#######.###.###.#.#####.#.#.#.#.# +#...###.#...#...#.......#.#...#...#.#.#.###...#.#.#...#.#...#.....#.#.#...#.....#.....#.#.#...#.#.#.#...###...#.....#...#...#.#.....#.#.#.#.# +#.#.###.#.#.#.###.#######.#######.#.#.#.###.#.#.#.#.#.#.###.#####.#.#.#.#######.#######.#.###.#.#.#.#.#######.#.#####.###.###.#.#####.#.#.#.# +#.#...#...#...###...#.....#.......#.#.#.#...#...#.#.#.#.#...###...#.#.#.#.....#.....#...#...#...#.#.#.#...#...#.......#...#...#.......#...#.# +#.###.#############.#.#####.#######.#.#.#.#######.#.#.#.#.#####.###.#.#.#.###.#####.#.#####.#####.#.#.#.#.#.###########.###.###############.# +#...#...###...#...#...#...#...#...#.#.#.#...#.....#.#.#.#.#...#.#...#.#.#.#...#...#.#.#...#...#...#.#.#.#.#.#...........#...#...#...#...#...# +###.###.###.#.#.#.#####.#.###.#.#.#.#.#.###.#.#####.#.#.#.#.#.#.#.###.#.#.#.###.#.#.#.#.#.###.#.###.#.#.#.#.#.###########.###.#.#.#.#.#.#.### +#...#...#...#...#.#.....#...#...#.#...#.....#...#...#.#.#.#.#.#.#.....#...#.#...#.#.#.#.#.#...#.#...#...#...#...#...###...#...#.#.#.#.#...### +#.###.###.#######.#.#######.#####.#############.#.###.#.#.#.#.#.###########.#.###.#.#.#.#.#.###.#.#############.#.#.###.###.###.#.#.#.####### +#...#...#.......#.#.......#.#...#...........#...#.#...#.#...#.#...#.........#.###.#.#...#.#...#...#.....#.......#.#.#...#...###...#...#...### +###.###.#######.#.#######.#.#.#.###########.#.###.#.###.#####.###.#.#########.###.#.#####.###.#####.###.#.#######.#.#.###.#############.#.### +###...#.#.......#.........#...#.............#.#...#.#...#...#.#...#.........#...#.#.#.....#...#...#...#...###...#.#.#.#...###...........#...# +#####.#.#.###################################.#.###.#.###.#.#.#.###########.###.#.#.#.#####.###.#.###.#######.#.#.#.#.#.#####.#############.# +#.....#...#.....#...........................#.#.#...#.#...#...#.........###...#.#...#.#.....###.#...#.........#...#...#.....#.#...........#.# +#.#########.###.#.#########################.#.#.#.###.#.###############.#####.#.#####.#.#######.###.#######################.#.#.#########.#.# +#.#...#...#.#...#.#...........#...#.....#...#...#...#.#...#...#.......#.#.....#.....#.#.#.....#...#...............#...#...#...#.#.......#...# +#.#.#.#.#.#.#.###.#.#########.#.#.#.###.#.#########.#.###.#.#.#.#####.#.#.#########.#.#.#.###.###.###############.#.#.#.#.#####.#.#####.##### +#...#...#...#.....#...#.....#.#.#.#...#.#...###...#.#.#...#.#.#.....#...#.....#...#.#...#...#.....#...........###...#.#.#.....#...#...#.....# +#####################.#.###.#.#.#.###.#.###.###.#.#.#.#.###.#.#####.#########.#.#.#.#######.#######.#########.#######.#.#####.#####.#.#####.# +#...#.....###...#...#...#...#...#.....#...#.#...#.#.#.#...#.#...#...###.......#.#...###...#...#...#.#.......#.....#...#.....#.......#.......# +#.#.#.###.###.#.#.#.#####.###############.#.#.###.#.#.###.#.###.#.#####.#######.#######.#.###.#.#.#.#.#####.#####.#.#######.################# +#.#.#...#.#...#...#.......#...#.....#...#...#...#.#...###.#.###.#.....#.......#.......#.#.###...#...#.#...#.#.....#.#.....#...#...#...#...### +#.#.###.#.#.###############.#.#.###.#.#.#######.#.#######.#.###.#####.#######.#######.#.#.###########.#.#.#.#.#####.#.###.###.#.#.#.#.#.#.### +#.#.#...#.#...#...#.......#.#...###...#.........#...###...#...#.#...#.###...#.#...#...#.#...........#...#.#.#.#...#...###...#...#...#...#...# +#.#.#.###.###.#.#.#.#####.#.#######################.###.#####.#.#.#.#.###.#.#.#.#.#.###.###########.#####.#.#.#.#.#########.###############.# +#.#.#.#...###...#...#...#...###.........#.........#.#...#...#.#...#.#...#.#...#.#.#.###...........#.......#...#.#.....#...#.#.......#...#...# +#.#.#.#.#############.#.#######.#######.#.#######.#.#.###.#.#.#####.###.#.#####.#.#.#############.#############.#####.#.#.#.#.#####.#.#.#.### +#.#...#...#...#...#...#.......#.......#...#.....#.#.#...#.#.#.#.....#...#.#...#.#.#.....###...###...............#.....#.#.#.#.....#...#...### +#.#######.#.#.#.#.#.#########.#######.#####.###.#.#.###.#.#.#.#.#####.###.#.#.#.#.#####.###.#.###################.#####.#.#.#####.########### +#...#...#.#.#.#.#.#.........#.#.......###...#...#...#...#.#...#...#...###.#.#.#.#.......#...#...#.................#...#.#.#.#...#.#.........# +###.#.#.#.#.#.#.#.#########.#.#.#########.###.#######.###.#######.#.#####.#.#.#.#########.#####.#.#################.#.#.#.#.#.#.#.#.#######.# +#...#.#.#...#.#.#.#.........#...#...#...#...#.#...###...#.....###.#.....#.#.#.#.#.........#...#.#...................#...#.#.#.#.#...#...#...# +#.###.#.#####.#.#.#.#############.#.#.#.###.#.#.#.#####.#####.###.#####.#.#.#.#.#.#########.#.#.#########################.#.#.#.#####.#.#.### +#...#.#.....#...#.#.......#.....#.#...#.#...#...#...#...#...#.#...#...#.#.#.#.#.#.#...#...#.#.#.................#...#.....#...#.......#...### +###.#.#####.#####.#######.#.###.#.#####.#.#########.#.###.#.#.#.###.#.#.#.#.#.#.#.#.#.#.#.#.#.#################.#.#.#.####################### +###...###...#...#.......#...###...#...#.#.#.......#.#.....#.#.#.#...#...#.#.#...#...#...#...#...............###...#...###...........#...#...# +#########.###.#.#######.###########.#.#.#.#.#####.#.#######.#.#.#.#######.#.###############################.#############.#########.#.#.#.#.# +#...#.....#...#.......#.###...#.....#...#.#.#...#...#...###...#...#...###...###.............................#.......#...#.#.........#.#...#.# +#.#.#.#####.#########.#.###.#.#.#########.#.#.#.#####.#.###########.#.#########.#############################.#####.#.#.#.#.#########.#####.# +#.#...#.....#...###...#.....#...#.........#...#...#...#.#...###.....#.....#.....#.....#.....#...............#.#...#...#...#...#...#...#...#.# +#.#####.#####.#.###.#############.###############.#.###.#.#.###.#########.#.#####.###.#.###.#.#############.#.#.#.###########.#.#.#.###.#.#.# +#.#...#.#.....#.....#...#...#...#.#...............#.#...#.#.....#.........#.......###...###...#...#.........#.#.#...#...#...#.#.#.#.#...#...# +#.#.#.#.#.###########.#.#.#.#.#.#.#.###############.#.###.#######.#############################.#.#.#########.#.###.#.#.#.#.#.#.#.#.#.####### +#...#.#.#.#.........#.#...#...#...#.............###.#.....#######....E#...#...#...#.............#...#.........#...#.#.#.#.#.#...#...#.......# +#####.#.#.#.#######.#.#########################.###.###################.#.#.#.#.#.#.#################.###########.#.#.#.#.#.###############.# +###...#.#.#.#.....#...###.................#S###.....###################.#.#.#...#.#...............#...###...#.....#...#...#...#.............# +###.###.#.#.#.###.#######.###############.#.###########################.#.#.#####.###############.#.#####.#.#.###############.#.############# +#...#...#...#...#.###...#...#...#.......#.#.#######################...#.#.#.....#...............#...#.....#.#...........#.....#.............# +#.###.#########.#.###.#.###.#.#.#.#####.#.#.#######################.#.#.#.#####.###############.#####.#####.###########.#.#################.# +#.#...#...#.....#.#...#.###...#...#.....#...###########...#########.#.#.#.#...#...........#.....#...#.#...#.............#.....#...#...#...#.# +#.#.###.#.#.#####.#.###.###########.###################.#.#########.#.#.#.#.#.###########.#.#####.#.#.#.#.###################.#.#.#.#.#.#.#.# +#...###.#.#.....#.#...#.#...###...#.#.....#...#...#...#.#.....#.....#...#...#.......#.....#...#...#.#...#...........#...#...#.#.#.#.#.#.#...# +#######.#.#####.#.###.#.#.#.###.#.#.#.###.#.#.#.#.#.#.#.#####.#.###################.#.#######.#.###.###############.#.#.#.#.#.#.#.#.#.#.##### +###...#.#.......#...#.#...#.....#...#.#...#.#.#.#...#.#.#.....#.........#.....#...#...#.....#.#...#.................#.#...#.#...#...#.#.....# +###.#.#.###########.#.###############.#.###.#.#.#####.#.#.#############.#.###.#.#.#####.###.#.###.###################.#####.#########.#####.# +#...#...#...#.....#...#...............#.....#.#...#...#.#.......###...#...###...#.....#.#...#...#.........#...#...###.#.....#.......#...#...# +#.#######.#.#.###.#####.#####################.###.#.###.#######.###.#.###############.#.#.#####.#########.#.#.#.#.###.#.#####.#####.###.#.### +#.........#...###...#...###.............#.....#...#.....#.......#...#...###...#.....#.#.#.....#.#...#...#...#...#.....#.......#...#...#.#...# +###################.#.#####.###########.#.#####.#########.#######.#####.###.#.#.###.#.#.#####.#.#.#.#.#.#######################.#.###.#.###.# +###...#.......#####...#.....#.........#.#.......#.....#...#.....#.....#...#.#...#...#...###...#...#...#.....#...#...#...........#.#...#.....# +###.#.#.#####.#########.#####.#######.#.#########.###.#.###.###.#####.###.#.#####.#########.###############.#.#.#.#.#.###########.#.######### +#...#.#.....#...###...#.....#.#.......#.#.....#...###...###...#...###...#.#...#...#...#...#.........#.....#...#...#...#...#...###.#...#...### +#.###.#####.###.###.#.#####.#.#.#######.#.###.#.#############.###.#####.#.###.#.###.#.#.#.#########.#.###.#############.#.#.#.###.###.#.#.### +#...#.....#...#.#...#.#...#...#.......#.#...#.#.........#...#.#...#.....#.#...#.#...#...#...#...###...###...........###.#...#...#...#...#...# +###.#####.###.#.#.###.#.#.###########.#.###.#.#########.#.#.#.#.###.#####.#.###.#.#########.#.#.###################.###.#######.###.#######.# +#...#.....###.#.#...#...#...#...#.....#...#.#.#.........#.#...#...#.....#.#...#.#.#.......#...#.#.....###...#...#...#...#...#...###.#...#...# +#.###.#######.#.###.#######.#.#.#.#######.#.#.#.#########.#######.#####.#.###.#.#.#.#####.#####.#.###.###.#.#.#.#.###.###.#.#.#####.#.#.#.### +#...#.###...#.#.###.....#...#.#.#.......#...#...###...###...#...#.....#.#...#.#.#...#.....#.....#...#.....#...#...#...#...#...#...#...#.#...# +###.#.###.#.#.#.#######.#.###.#.#######.###########.#.#####.#.#.#####.#.###.#.#.#####.#####.#######.###############.###.#######.#.#####.###.# +#...#.....#...#.........#.....#.......#.....#.......#...###...#...#...#.#...#.#.#.....#.....#.....#...#...........#...#.#...#...#...###...#.# +#.###################################.#####.#.#########.#########.#.###.#.###.#.#.#####.#####.###.###.#.#########.###.#.#.#.#.#####.#####.#.# +#.#...#.....#.........#...#...#.....#.......#.....#.....#...#...#.#.#...#...#.#.#.....#...###.#...###...#.........#...#...#...#...#.#...#...# +#.#.#.#.###.#.#######.#.#.#.#.#.###.#############.#.#####.#.#.#.#.#.#.#####.#.#.#####.###.###.#.#########.#########.###########.#.#.#.#.##### +#.#.#.#.###...#...#...#.#...#.#.#...#.....#...#...#.#.....#.#.#.#.#.#...#...#.#...#...#...#...#...#.....#.....#.....#.........#.#.#...#.....# +#.#.#.#.#######.#.#.###.#####.#.#.###.###.#.#.#.###.#.#####.#.#.#.#.###.#.###.###.#.###.###.#####.#.###.#####.#.#####.#######.#.#.#########.# +#.#.#.#.#.....#.#...#...#.....#.#...#...#.#.#.#.#...#...#...#.#.#.#.###.#.###...#.#.#...###...#...#...#.#...#...#...#.......#...#.........#.# +#.#.#.#.#.###.#.#####.###.#####.###.###.#.#.#.#.#.#####.#.###.#.#.#.###.#.#####.#.#.#.#######.#.#####.#.#.#.#####.#.#######.#############.#.# +#.#.#...#...#...#...#.#...#...#.#...#...#.#.#.#.#.#...#.#.#...#...#.#...#...#...#...#.#.....#.#...#...#.#.#.#...#.#.#.....#.#.........#...#.# +#.#.#######.#####.#.#.#.###.#.#.#.###.###.#.#.#.#.#.#.#.#.#.#######.#.#####.#.#######.#.###.#.###.#.###.#.#.#.#.#.#.#.###.#.#.#######.#.###.# +#...###...#.....#.#.#.#.#...#.#.#...#...#...#.#.#.#.#.#.#.#.....#...#.###...#.#.......#.#...#.#...#...#.#.#.#.#.#.#.#...#.#...#.......#.....# +#######.#.#####.#.#.#.#.#.###.#.###.###.#####.#.#.#.#.#.#.#####.#.###.###.###.#.#######.#.###.#.#####.#.#.#.#.#.#.#.###.#.#####.############# +#.......#.......#.#.#.#...#...#.###...#.....#.#.#...#.#.#.....#.#...#...#.....#...#...#.#...#.#.......#...#.#.#...#.#...#.......###.........# +#.###############.#.#.#####.###.#####.#####.#.#.#####.#.#####.#.###.###.#########.#.#.#.###.#.#############.#.#####.#.#############.#######.# +#.....#...#...#...#.#.....#...#.#.....#...#.#...###...#...#...#...#.#...#...#.....#.#.#.#...#.........#...#.#.....#...#...#.........#.......# +#####.#.#.#.#.#.###.#####.###.#.#.#####.#.#.#######.#####.#.#####.#.#.###.#.#.#####.#.#.#.###########.#.#.#.#####.#####.#.#.#########.####### +#.....#.#.#.#...#...#...#.#...#.#.....#.#...#.......#.....#.#...#.#.#.....#.#.#...#.#.#.#.#.........#...#.#.#...#.......#...#.......#.......# +#.#####.#.#.#####.###.#.#.#.###.#####.#.#####.#######.#####.#.#.#.#.#######.#.#.#.#.#.#.#.#.#######.#####.#.#.#.#############.#####.#######.# +#...#...#.#...###...#.#...#...#...###.#.....#...#...#.#.....#.#.#.#...#...#.#...#.#.#...#.#.......#...#...#...#.#...#...#...#.....#.........# +###.#.###.###.#####.#.#######.###.###.#####.###.#.#.#.#.#####.#.#.###.#.#.#.#####.#.#####.#######.###.#.#######.#.#.#.#.#.#.#####.########### +#...#...#...#.#.....#.....#...#...#...#.....###.#.#.#.#.....#.#...#...#.#.#.#.....#.#.....#...#...#...#.......#...#.#.#...#.#...#...#.......# +#.#####.###.#.#.#########.#.###.###.###.#######.#.#.#.#####.#.#####.###.#.#.#.#####.#.#####.#.#.###.#########.#####.#.#####.#.#.###.#.#####.# +#.#.....###...#.....#.....#...#.#...#...#.......#.#.#.#.....#.....#...#.#...#.#...#.#...#...#.#...#...#.......#...#.#.#.....#.#...#...#...#.# +#.#.###############.#.#######.#.#.###.###.#######.#.#.#.#########.###.#.#####.#.#.#.###.#.###.###.###.#.#######.#.#.#.#.#####.###.#####.#.#.# +#.#...#...#.........#...#.....#.#.#...###.#...#...#.#.#.#...#...#...#.#.....#...#.#.#...#.###...#.#...#.......#.#...#.#...#...###...#...#...# +#.###.#.#.#.###########.#.#####.#.#.#####.#.#.#.###.#.#.#.#.#.#.###.#.#####.#####.#.#.###.#####.#.#.#########.#.#####.###.#.#######.#.####### +#...#...#.#.#.....#...#.#.#.....#.#.#...#...#.#.#...#.#...#.#.#...#.#...#...#.....#.#...#.....#...#.#...#.....#...#...#...#.###...#.#.......# +###.#####.#.#.###.#.#.#.#.#.#####.#.#.#.#####.#.#.###.#####.#.###.#.###.#.###.#####.###.#####.#####.#.#.#.#######.#.###.###.###.#.#.#######.# +#...#.....#.#...#.#.#.#.#...#.....#...#...###...#.....#.....#.#...#...#...###.......#...#...#.....#...#.#.......#.#...#...#.....#.#.#...#...# +#.###.#####.###.#.#.#.#.#####.###########.#############.#####.#.#####.###############.###.#.#####.#####.#######.#.###.###.#######.#.#.#.#.### +#...#.....#.#...#.#.#...#...#.....#.......#.....#.......#...#.#...#...###...#...#...#.#...#.#...#.....#...#...#.#.#...#...#.......#.#.#.#...# +###.#####.#.#.###.#.#####.#.#####.#.#######.###.#.#######.#.#.###.#.#####.#.#.#.#.#.#.#.###.#.#.#####.###.#.#.#.#.#.###.###.#######.#.#.###.# +###.#...#.#.#.###.#.#.....#.......#.........#...#...#...#.#.#...#.#.#.....#...#...#...#.#...#.#.#...#...#.#.#...#.#.#...#...#...#...#.#...#.# +###.#.#.#.#.#.###.#.#.#######################.#####.#.#.#.#.###.#.#.#.#################.#.###.#.#.#.###.#.#.#####.#.#.###.###.#.#.###.###.#.# +#...#.#.#.#.#.#...#.#.......#.......#.......#...###.#.#.#.#...#.#.#.#.....#...#.....#...#...#.#.#.#.#...#.#...#...#.#...#.....#.#...#...#.#.# +#.###.#.#.#.#.#.###.#######.#.#####.#.#####.###.###.#.#.#.###.#.#.#.#####.#.#.#.###.#.#####.#.#.#.#.#.###.###.#.###.###.#######.###.###.#.#.# +#.#...#.#.#.#.#.#...###.....#.#.....#.....#.#...#...#.#.#.#...#.#.#.....#...#.#...#.#...#...#.#.#.#.#...#...#.#.#...###...#...#.###.#...#.#.# +#.#.###.#.#.#.#.#.#####.#####.#.#########.#.#.###.###.#.#.#.###.#.#####.#####.###.#.###.#.###.#.#.#.###.###.#.#.#.#######.#.#.#.###.#.###.#.# +#.#...#.#.#.#.#.#.#.....#.....#.......#...#.#.###...#.#...#.....#.#...#.....#.#...#.#...#...#.#.#.#.#...#...#.#.#...###...#.#.#...#.#...#...# +#.###.#.#.#.#.#.#.#.#####.###########.#.###.#.#####.#.###########.#.#.#####.#.#.###.#.#####.#.#.#.#.#.###.###.#.###.###.###.#.###.#.###.##### +#.#...#.#.#.#.#.#.#.#...#.#...........#...#.#.....#.#...#.........#.#...#...#.#...#.#.....#.#.#.#.#.#...#...#.#...#...#...#.#.#...#...#.....# +#.#.###.#.#.#.#.#.#.#.#.#.#.#############.#.#####.#.###.#.#########.###.#.###.###.#.#####.#.#.#.#.#.###.###.#.###.###.###.#.#.#.#####.#####.# +#...###...#...#...#...#...#...............#.......#.....#...........###...###.....#.......#...#...#.....###...###.....###...#...#####.......# +############################################################################################################################################# + +100 diff --git a/2024/day20/test.txt b/2024/day20/test.txt new file mode 100755 index 0000000..30d5061 --- /dev/null +++ b/2024/day20/test.txt @@ -0,0 +1,17 @@ +############### +#...#...#.....# +#.#.#.#.#.###.# +#S#...#.#.#...# +#######.#.#.### +#######.#.#...# +#######.#.###.# +###..E#...#...# +###.#######.### +#...###...#...# +#.#####.#.###.# +#.#...#.#.#...# +#.#.#.#.#.#.### +#...#...#...### +############### + +0