diff --git a/day15/input b/day15/input new file mode 100644 index 0000000..27a6cd2 --- /dev/null +++ b/day15/input @@ -0,0 +1,71 @@ +################################################## +#O...........##..OO..O.OO..O......#OOOO.......#.## +#O..#....O.....#O........O.O........O.O.O.#..O..O# +#.O.O.......O.OO..O#O.OO...O.....O#O.##..O.......# +#O.O...O.#...O..O##.OOO.OOO#....O....O#O.O#....O.# +#.O#.#O.O.O.....O...O..O.....O...O.O...#OO..#....# +#....O..O...OO.#.O.O.O..O.#........OO..O..#.O...O# +##O...O.O..OO..O.O..OOO...O#......O.....#..O....O# +#O.O.......OOOO....O.#OO.O...O..O.#..O#O.O.O#....# +#.O.O......O..OO...........OO.OOO.#O.OO#O........# +#O......O.O.O...O.#OO.....O.OOO..O.....O.O.#..OO.# +#..O.O...O.OOO.#....O.#O....O...O..OOO...O.....O.# +#.OO..O...O.O.O.OOOO.O...OOO..OO.........##..O...# +#..O...O....O...O.#O..O......O.........#.......#O# +#..O.O.#O.O.OO#..#O#..OO..O......#..O.O....#...O.# +#....OOOO.OO....OO#.O.OOO.O.O..........#O#...#.O.# +#...O.....OO...O.#O..O..O.......#..OOO#O..#......# +#.OO..O.O###O.......O....OOOO..O##.O.OO.#........# +#.O.O..O#.........#.OO.OOOO..OO..#O..O.O...OO#...# +#.O..#OO.O.O...O.O..O..OO...OO.O...#.#.O#O.#O....# +##.O.OO.O.O...OOO..OO.OOO...........O....#.O...#O# +#O.........O.......OOO....#OO..O...#O.OO..#..O.OO# +#..OO.#O........O....O...O..OO......O...O..O.....# +#..O..OOO.O...#O#.O..O.O.O......O......O.........# +#OO.O...OOO.......O.....@.O.O.....#O..OO...OO..O.# +#.O.O....#O#...O.O...O.O.OO.##..O.#...O...OO...O.# +#...OO.OOO...#OO#OO....O.#.O...O.O.........O.O#..# +#..O.O........#...#.#....#..#O.O.#.....#.OO..O.#.# +#..O..#OOO...#.#........O.#..O.......O.....OO...O# +#.##OO.O......OOO.#..O....O..#O.O..O....OO.......# +#O..OO...O...O.#O.#O.....#O....#..OO.O#.#.OOO...O# +#O..O...O..O.O...O.O..O.#...O.OO..#.OO.O.........# +#....OO.O.....O.OO..O....O.OO.O...OO.O.#...O..O### +#.OO..O..##OOOO.#.O#....OO.....O..OO.O.#O.OOO..O.# +#..O....#.....O....OO.....OOO.O..OO..OOO#O..O.O..# +##...O.O...OO...O....OOO...O....OO...OOOOO#..#...# +#...O###....O......O...#.......#..........O#.OO.O# +#O.......O.O.OOO..#O....O......OOO.O.O.O.O.O.....# +#O.#O....O...#.OO.....#O...O..O...O#.O...........# +#.........O......O....O.......OO.O......OO....#..# +#..O...O.....O.#.#..#O...#...O..OO..O#O#..O.O..OO# +#.O.O#...OO...O....O......OO......O..###..O..OOO.# +#O...#...........O..O.#.#...O.O......O....O.O.#.## +#.#O...#..O.OO.O.O....O.OO........O...OOOOO...#O.# +#....#......#.....O..OO..O.O.#.#.#O.........#.O..# +#O......O.................OO.#O..#..#.#..O...OOO.# +#...OO.#....O...OO...#.....O..O...#OO....O.....O.# +#.O.O.O....#..#OO.......O.#...O..O#O...#O..O.....# +#...O...O...##..#.O.#..O.O..#...O.....OO.O..#.O..# +################################################## + +v>>v<>^vvv^^v<><^<^v<^^>>>>>>^^vv^>v^>>^^^^<^^<^^v>vvv^><<<>^^v^vvvv<<>>^>>v^<^v^v<>>^<^><^<^^^v^<><<>v>>^^>v<>^>>><>v>^<^<>^^>^>v><><^v>>>>v^^<<^>>^>^<<>vv^><^<^><>v^>>^<^v>>v><>>^<^<<^^<^<>^v^>v^<>>v<>^vv>><^^>^^<^>>>^^>^<^<><>v>>>>>^><>vvv<<>>><><<^<>v>^v>v^^^<<<<<^^^v>^^>^^v^^vv>v>v<>^>>^^^vv^>^<^^<<^^^v<<>>^>>>^<<<<>><>>^^v^v^>v>>^v^^^v^<^v^>vv^v>vv>v>^>^v^^>>>><>^>>^v<^^^^v^^>>^>>vvvv<>>^<<>^<>>^^^v^><<><^<<>^^>><^vv>v<>>^^^>^^vv^^>>><>vvv>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>>vv^<<v^vv^>>v<^^<<^>^^<^v<<^>^^v<<<<<><<^>>v>v^^>^>^<><<<v^^<<^vvv<^^^<>^><^<^>>v^^>>>v>^<<<<^^>^v>>>^v^><^<<<>><^><<><>><>>^^^>v^>>>^>^>v<v<>^><^>^v<>^><>v><>^^vv^<^<<^v^^<<<>>><>><><>^v<><<v^<<<^^>^^<>^v^v^^<<v^>>^>v><>><>v><>>^vv^v^>>^vv>>^<^^><<>v^<^>>><><>^^>^^v<<<>><<<<><>^<^v>^<<>>>v><^>^<>vv<>>v>^<<>>v><^<<^<^>vv^v>>^v^v>^><^v^vvv^>>>><<>><<^^^<^^<<v^vv>v^^v^<>><<<^v><>>>vv^>v>^^>vv>^><vv^^>^<><^>^<>><<><><>^^<^<>>^^<<>>>^><><^<><>^>^v^<>vv^^>v^<^<>^v<>v>^v^^v<<^^v^>><<>>v^^<<<^v><^^<<^<>vv<>^><>><><^>v<<>v<^^>v^>^v<><<<^<<>v^<<^<<^^>>><<>^^^v<^<<v< diff --git a/day15/main.go b/day15/main.go new file mode 100644 index 0000000..e79d516 --- /dev/null +++ b/day15/main.go @@ -0,0 +1,194 @@ +package main + +import ( + "fmt" + "strings" + + "git.mstar.dev/mstar/aoc24/util" +) + +type Area struct { + a [][]rune +} + +func parseLinesToMap(lines []string) Area { + out := [][]rune{} + + for _, line := range lines { + out = append(out, []rune(strings.TrimSpace(line))) + } + + return Area{out} +} + +func parseInput(in []byte) (Area, []rune) { + tmp := strings.Split(string(in), "\n\n") + return parseLinesToMap(strings.Split(tmp[0], "\n")), []rune(tmp[1]) +} + +func (area *Area) applyAction(action rune) { + botX := -1 + botY := -1 +outer: + for iy, line := range area.a { + for ix, char := range line { + if char == '@' { + botX = ix + botY = iy + break outer + } + } + } + area.move(util.Vec2{X: int64(botX), Y: int64(botY)}, action) +} + +func (area *Area) move(from util.Vec2, action rune) bool { + switch action { + case '<': + return area.moveLeft(from) + case '>': + return area.moveRight(from) + case 'v': + return area.moveDown(from) + case '^': + return area.moveUp(from) + default: + return false + } +} + +func (area *Area) moveLeft(from util.Vec2) bool { + target := area.a[from.Y][from.X-1] + switch target { + case '#': + return false + case '.': + area.a[from.Y][from.X-1] = area.a[from.Y][from.X] + area.a[from.Y][from.X] = '.' + return true + default: + return area.moveLeft(from.Add(util.Vec2{X: -1, Y: 0})) && area.moveLeft(from) + } +} + +func (area *Area) moveRight(from util.Vec2) bool { + target := area.a[from.Y][from.X+1] + switch target { + case '#': + // fmt.Println("Wall") + return false + case '.': + // fmt.Println("moving right") + area.a[from.Y][from.X+1] = area.a[from.Y][from.X] + area.a[from.Y][from.X] = '.' + return true + default: + return area.moveRight(from.Add(util.Vec2{X: 1, Y: 0})) && area.moveRight(from) + } +} + +func (area *Area) moveUp(from util.Vec2) bool { + target := area.a[from.Y-1][from.X] + switch target { + case '#': + return false + case '.': + area.a[from.Y-1][from.X] = area.a[from.Y][from.X] + area.a[from.Y][from.X] = '.' + return true + case '[': + return area.moveUp(from.Add(util.Vec2{X: 0, Y: -1})) && + area.moveUp(from.Add(util.Vec2{X: 1, Y: -1})) && + area.moveUp(from) && + area.moveUp(from.Add(util.Vec2{X: 1, Y: 0})) + case ']': + return area.moveUp(from.Add(util.Vec2{X: 0, Y: -1})) && + area.moveUp(from.Add(util.Vec2{X: -1, Y: -1})) && + area.moveUp(from) && + area.moveUp(from.Add(util.Vec2{X: -1, Y: 0})) + default: + return area.moveUp(from.Add(util.Vec2{X: 0, Y: -1})) && area.moveUp(from) + } +} + +func (area *Area) moveDown(from util.Vec2) bool { + target := area.a[from.Y+1][from.X] + switch target { + case '#': + return false + case '.': + area.a[from.Y+1][from.X] = area.a[from.Y][from.X] + area.a[from.Y][from.X] = '.' + return true + case '[': + return area.moveUp(from.Add(util.Vec2{X: 0, Y: 1})) && + area.moveUp(from.Add(util.Vec2{X: 1, Y: 1})) && + area.moveUp(from) && + area.moveUp(from.Add(util.Vec2{X: 1, Y: 0})) + case ']': + return area.moveUp(from.Add(util.Vec2{X: 0, Y: 1})) && + area.moveUp(from.Add(util.Vec2{X: -1, Y: 1})) && + area.moveUp(from) && + area.moveUp(from.Add(util.Vec2{X: -1, Y: 0})) + default: + return area.moveDown(from.Add(util.Vec2{X: 0, Y: 1})) && area.moveDown(from) + } +} + +func (area *Area) visualise() string { + builder := strings.Builder{} + for _, line := range area.a { + builder.WriteString(string(line)) + builder.WriteRune('\n') + } + + return builder.String() +} + +func (area *Area) calcPosScore() int { + score := 0 + for iy, line := range area.a { + for ix, char := range line { + if char == 'O' || char == '[' { + score += calcPosVal(ix, iy) + } + } + } + return score +} + +func Widen(in string) string { + return strings.ReplaceAll( + strings.ReplaceAll( + strings.ReplaceAll(strings.ReplaceAll(in, ".", ".."), "@", "@."), + "#", + "##", + ), + "O", + "[]", + ) +} + +func calcPosVal(x, y int) int { + return x + y*100 +} + +func main() { + rawInput := util.LoadFileFromArgs() + area, inputs := parseInput(rawInput) + // fmt.Println(area.visualise()) + for _, action := range inputs { + // fmt.Println(string(action)) + area.applyAction(action) + // fmt.Println(area.visualise()) + } + fmt.Printf("Task 1: %d\n", area.calcPosScore()) + + wArea, _ := parseInput([]byte(Widen(string(rawInput)))) + fmt.Println(wArea.visualise()) + for _, action := range inputs { + wArea.applyAction(action) + fmt.Println(wArea.visualise()) + } + fmt.Printf("Task 2: %d\n", wArea.calcPosScore()) +} diff --git a/day15/sample1 b/day15/sample1 new file mode 100644 index 0000000..8163605 --- /dev/null +++ b/day15/sample1 @@ -0,0 +1,10 @@ +######## +#..O.O.# +##@.O..# +#...O..# +#.#.O..# +#...O..# +#......# +######## + +<^^>>>vv>v<< diff --git a/day15/sample2 b/day15/sample2 new file mode 100644 index 0000000..84cf1fb --- /dev/null +++ b/day15/sample2 @@ -0,0 +1,21 @@ +########## +#..O..O.O# +#......O.# +#.OO..O.O# +#..O@..O.# +#O#..O...# +#O..O..O.# +#.OO.O.OO# +#....O...# +########## + +^v>^vv^v>v<>v^v<<><>>v^v^>^<<<><^ +vvv<<^>^v^^><<>>><>^<<><^vv^^<>vvv<>><^^v>^>vv<>v<<<^<^^>>>^<>vv>v^v^<>><>>>><^^>vv>v<^^^>>v^v^<^^>v^^>v^<^v>v<>>v^v^v^^<^^vv< +<>^^^^>>>v^<>vvv^>^^^vv^^>v<^^^^v<>^>vvvv><>>v^<<^^^^^ +^><^><>>><>^^<<^^v>>><^^>v>>>^v><>^v><<<>vvvv>^<><<>^>< +^>><>^v<><^vvv<^^<><^v<<<><<<^^<^>>^<<<^>>^v^>>^v>vv>^<<^v<>><<><<>v<^vv<<<>^^v^>^^>>><<^v>>v^v><^^>>^<>vv^ +<><^^>^^^<>^vv<<^><<><<><<<^^<<<^<<>><<><^^^>^^<>^>v<> +^^>vv<^v^v^<>^^^>>>^^vvv^>vvv<>>>^<^>>>>>^<<^v>^vvv<>^<>< +v^^>>><<^^<>>^v^v^<<>^<^v^v><^<<<><<^vv>>v>v^<<^ diff --git a/day15/sample3 b/day15/sample3 new file mode 100644 index 0000000..6ee6098 --- /dev/null +++ b/day15/sample3 @@ -0,0 +1,9 @@ +####### +#...#.# +#.....# +#..OO@# +#..O..# +#.....# +####### + +