From 2e00ebead4a953ee030a86ef3c2dfd4356582405 Mon Sep 17 00:00:00 2001 From: TheCK Date: Thu, 14 Dec 2023 11:22:34 +0100 Subject: [PATCH] AOC 2023 day 14 --- adventofcode/README.md | 6 +- .../org/ck/adventofcode/year2023/Day14.java | 163 ++++++++++++++++-- .../ck/adventofcode/year2023/Day14Test.java | 3 - .../adventofcode/year2023/day14/01.result.txt | 1 + .../org/ck/adventofcode/year2023/day14/01.txt | 100 +++++++++++ .../year2023/day14/01a.result.txt | 1 + .../ck/adventofcode/year2023/day14/01a.txt | 10 ++ .../adventofcode/year2023/day14/02.result.txt | 1 + .../org/ck/adventofcode/year2023/day14/02.txt | 100 +++++++++++ .../year2023/day14/02a.result.txt | 1 + .../ck/adventofcode/year2023/day14/02a.txt | 10 ++ 11 files changed, 380 insertions(+), 16 deletions(-) create mode 100644 adventofcode/src/test/resources/org/ck/adventofcode/year2023/day14/01.result.txt create mode 100644 adventofcode/src/test/resources/org/ck/adventofcode/year2023/day14/01.txt create mode 100644 adventofcode/src/test/resources/org/ck/adventofcode/year2023/day14/01a.result.txt create mode 100644 adventofcode/src/test/resources/org/ck/adventofcode/year2023/day14/01a.txt create mode 100644 adventofcode/src/test/resources/org/ck/adventofcode/year2023/day14/02.result.txt create mode 100644 adventofcode/src/test/resources/org/ck/adventofcode/year2023/day14/02.txt create mode 100644 adventofcode/src/test/resources/org/ck/adventofcode/year2023/day14/02a.result.txt create mode 100644 adventofcode/src/test/resources/org/ck/adventofcode/year2023/day14/02a.txt diff --git a/adventofcode/README.md b/adventofcode/README.md index bcf92259..d2ae3af8 100644 --- a/adventofcode/README.md +++ b/adventofcode/README.md @@ -1218,7 +1218,7 @@ [20222402tests]: src/test/java/org/ck/adventofcode/year2022/day24/Part2Test.java [20222501tests]: src/test/java/org/ck/adventofcode/year2022/day25/Part1Test.java -# 2023 (26/49) +# 2023 (28/49) | # | Name | Solution | Test | |---------:|-------------------------------------------------------------|:------------------------------------:|:---------------------------------:| @@ -1248,8 +1248,8 @@ | 20231202 | [Day 12: Hot Springs - Part 2][20231202] | ✅[💾][20231202solution] | ✅[💾][20231202tests] | | 20231301 | [Day 13: Point of Incidence][20231301] | ✅[💾][20231301solution] | ✅[💾][20231301tests] | | 20231302 | [Day 13: Point of Incidence - Part 2][20231302] | ✅[💾][20231302solution] | ✅[💾][20231302tests] | -| 20231401 | [Day 14: ][20231401] | [💾][20231401solution] | [💾][20231401tests] | -| 20231402 | [Day 14: - Part 2][20231402] | [💾][20231402solution] | [💾][20231402tests] | +| 20231401 | [Day 14: Parabolic Reflector Dish][20231401] | ✅[💾][20231401solution] | ✅[💾][20231401tests] | +| 20231402 | [Day 14: Parabolic Reflector Dish - Part 2][20231402] | ✅[💾][20231402solution] | ✅[💾][20231402tests] | | 20231501 | [Day 15: ][20231501] | [💾][20231501solution] | [💾][20231501tests] | | 20231502 | [Day 15: - Part 2][20231502] | [💾][20231502solution] | [💾][20231502tests] | | 20231601 | [Day 16: ][20231601] | [💾][20231601solution] | [💾][20231601tests] | diff --git a/adventofcode/src/main/java/org/ck/adventofcode/year2023/Day14.java b/adventofcode/src/main/java/org/ck/adventofcode/year2023/Day14.java index 48c7457a..e6ed51e0 100644 --- a/adventofcode/src/main/java/org/ck/adventofcode/year2023/Day14.java +++ b/adventofcode/src/main/java/org/ck/adventofcode/year2023/Day14.java @@ -1,31 +1,174 @@ package org.ck.adventofcode.year2023; -import java.util.Scanner; +import java.util.*; +import java.util.function.BiFunction; +import java.util.stream.Collectors; import org.ck.adventofcode.util.AOCSolution; import org.ck.codechallengelib.annotation.Solution; @Solution( id = 20231401, - name = "Day 14: ", + name = "Day 14: Parabolic Reflector Dish", url = "https://adventofcode.com/2023/day/14", - category = "2023", - solved = false) + category = "2023") @Solution( id = 20231402, - name = "Day 14: - Part 2", + name = "Day 14: Parabolic Reflector Dish - Part 2", url = "https://adventofcode.com/2023/day/14#part2", - category = "2023", - solved = false) + category = "2023") public class Day14 extends AOCSolution { @Override protected void runPartOne(final Scanner in) { - run(in); + run( + in, + 1, + (dish, cycle) -> { + tiltNorth(dish); + return 0; + }); } @Override protected void runPartTwo(final Scanner in) { - run(in); + final Map cache = new HashMap<>(); + + run( + in, + 1_000_000_000, + (dish, cycle) -> { + tiltNorth(dish); + tiltWest(dish); + tiltSouth(dish); + tiltEast(dish); + + String key = dish.stream().map(String::new).collect(Collectors.joining()); + if (cache.containsKey(key)) { + return cycle - cache.get(key); + } + + cache.put(key, cycle); + return 0; + }); + } + + private void run( + final Scanner in, + final int cycles, + final BiFunction, Integer, Integer> dishCycle) { + final List dish = new ArrayList<>(); + + while (in.hasNextLine()) { + dish.add(in.nextLine().toCharArray()); + } + + int cycle = 0; + while (cycle < cycles) { + final int cycleLength = dishCycle.apply(dish, cycle); + + if (cycleLength != 0) { + cycle += ((cycles - cycle) / cycleLength) * cycleLength; + } + + ++cycle; + } + + print(calcLoad(dish)); + } + + private long calcLoad(final List dish) { + long load = 0; + + for (int rowIndex = 0; rowIndex < dish.size(); ++rowIndex) { + final char[] row = dish.get(rowIndex); + + for (final char mirror : row) { + if (mirror == 'O') { + load += (dish.size() - rowIndex); + } + } + } + + return load; + } + + private void tiltNorth(final List dish) { + for (int rowIndex = 0; rowIndex < dish.size(); ++rowIndex) { + final char[] row = dish.get(rowIndex); + + for (int columnIndex = 0; columnIndex < row.length; ++columnIndex) { + if (row[columnIndex] == 'O') { + int rowAbove = rowIndex; + + while (rowAbove > 0 && dish.get(rowAbove - 1)[columnIndex] == '.') { + --rowAbove; + } + + if (rowIndex != rowAbove) { + dish.get(rowAbove)[columnIndex] = 'O'; + row[columnIndex] = '.'; + } + } + } + } + } + + private void tiltSouth(final List dish) { + for (int rowIndex = dish.size() - 1; rowIndex >= 0; --rowIndex) { + final char[] row = dish.get(rowIndex); + + for (int columnIndex = 0; columnIndex < row.length; ++columnIndex) { + if (row[columnIndex] == 'O') { + int rowBelow = rowIndex; + + while (rowBelow < dish.size() - 1 && dish.get(rowBelow + 1)[columnIndex] == '.') { + ++rowBelow; + } + + if (rowIndex != rowBelow) { + dish.get(rowBelow)[columnIndex] = 'O'; + row[columnIndex] = '.'; + } + } + } + } + } + + private void tiltWest(final List dish) { + for (int columnIndex = 0; columnIndex < dish.getFirst().length; ++columnIndex) { + for (int rowIndex = 0; rowIndex < dish.size(); ++rowIndex) { + if (dish.get(rowIndex)[columnIndex] == 'O') { + int columnToLeft = columnIndex; + + while (columnToLeft > 0 && dish.get(rowIndex)[columnToLeft - 1] == '.') { + --columnToLeft; + } + + if (columnIndex != columnToLeft) { + dish.get(rowIndex)[columnToLeft] = 'O'; + dish.get(rowIndex)[columnIndex] = '.'; + } + } + } + } } - private void run(final Scanner in) {} + private void tiltEast(final List dish) { + for (int columnIndex = dish.getFirst().length - 1; columnIndex >= 0; --columnIndex) { + for (int rowIndex = 0; rowIndex < dish.size(); ++rowIndex) { + if (dish.get(rowIndex)[columnIndex] == 'O') { + int columnToRight = columnIndex; + + while (columnToRight < dish.getFirst().length - 1 + && dish.get(rowIndex)[columnToRight + 1] == '.') { + ++columnToRight; + } + + if (columnIndex != columnToRight) { + dish.get(rowIndex)[columnToRight] = 'O'; + dish.get(rowIndex)[columnIndex] = '.'; + } + } + } + } + } } diff --git a/adventofcode/src/test/java/org/ck/adventofcode/year2023/Day14Test.java b/adventofcode/src/test/java/org/ck/adventofcode/year2023/Day14Test.java index fdd8ab21..20d7628e 100644 --- a/adventofcode/src/test/java/org/ck/adventofcode/year2023/Day14Test.java +++ b/adventofcode/src/test/java/org/ck/adventofcode/year2023/Day14Test.java @@ -1,21 +1,18 @@ package org.ck.adventofcode.year2023; import org.ck.adventofcode.util.BaseAOCTest; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; class Day14Test extends BaseAOCTest { @ParameterizedTest @ValueSource(strings = {"01", "01a"}) - @Disabled void testOne(String name) throws Exception { runTest(new Day14()::partOne, "day14/%s".formatted(name)); } @ParameterizedTest @ValueSource(strings = {"02", "02a"}) - @Disabled void testTwo(String name) throws Exception { runTest(new Day14()::partTwo, "day14/%s".formatted(name)); } diff --git a/adventofcode/src/test/resources/org/ck/adventofcode/year2023/day14/01.result.txt b/adventofcode/src/test/resources/org/ck/adventofcode/year2023/day14/01.result.txt new file mode 100644 index 00000000..ee84e27a --- /dev/null +++ b/adventofcode/src/test/resources/org/ck/adventofcode/year2023/day14/01.result.txt @@ -0,0 +1 @@ +113456 \ No newline at end of file diff --git a/adventofcode/src/test/resources/org/ck/adventofcode/year2023/day14/01.txt b/adventofcode/src/test/resources/org/ck/adventofcode/year2023/day14/01.txt new file mode 100644 index 00000000..415085f0 --- /dev/null +++ b/adventofcode/src/test/resources/org/ck/adventofcode/year2023/day14/01.txt @@ -0,0 +1,100 @@ +O.O#....O.O...O..OO#OO##..O..##...#..........OO..#.OO...................O..O##.#OOO...O#.#.#.O.O#OO. +.O..OO..O.O..O......OO.#....#O#.#.#.#.#.O.OO...#.O#.OOO.#.#.#.OO..#.#O...O.O.O.O#.#.O.O....#..O#O... +O....#..O..O.OO..#OO.O.....O#OOO..#.#......O...#..#..O......#O.#.O.#.O...#.#.#.........O#.......#OO. +......O.O##......###OO#..O#.#...O...O.....##.........#.OO.#........#OO.O....###...#.##..O........O.# +#.OO.....OOO....O.....OO.OOO..#O.OO...#...O......OO###........O..#.#.O..O......O#...O.....#.#...##.. +#..O.#..OO.OO.O.OOO#O...O......O..#O..O#.O.O.O#....O.#O.O.....#..#..O.O.#O..O....O#.O..#....O#...... +#..O#...O.O.O..O...#.O.#.O..........O.#.#.........O.......##...#..O.OO#......#.......O.#.#..#.OO##O. +O.O..O..#......#....#O....O..O#.OOO..#..O#.OO#.........O..##...O..#.........O##...O....O..O.O.O..O.. +O.O#.O...OO....O....##O.O......O.O..O....#...O...O##........#.......#....O..O.......O...#O.....#.... +..O.#..#..OO.O..#...#..O#OOO..#.O.#O#OOO....#..OOO.#O..O..#.OOOO.........O#..O..O...O.##..O......#.. +##..#..#.....O..OO###.........##..##..OO...#..#O.#......#O...O.....#........#....OO.#OO.#.O....#.O#O +.O.....O.O.O....#OO..O.##OO#..O.....O..#..O..#....O..O#....O..#.OO..O....OO..O.O..O#.....O.O.#O..OO. +O#O.##O#..................O.OO...#...#..#O....O..O..OO#.O#...##.O...##.OO#.....O.#.#...##..O.OO..O.. +O.....OO..OO..#OO#.....O.O.#....OO.#...###.......O#...##....##.O..##......#......O#O..OO.OO....O.... +.......O.O.#..O..O.#.O..O.O#O.#....##.OO.#...#.OO#..O...#..O...O...#.#...O#.....O#O........O...##.#O +#....O..O..OOO...#....#.##.#....O.............##O#...#..O.O.##..#.O..O.#...#.O.##O..##.#...O......## +.O...##.O.....#OO.O..O..#O.#.#...O....#...#...O..#O...........##..OO##...#...#..O#O.........O..#..#O +O...O...O..#..#OO.....OOO.#.........O..O.......#.#.#...OO##..O...O.....O#.#..O........#.#.O.O..##.#. +.###...#.....#..#O.O.......O.....O#.OO....##.OO.........O#...OO.OO#.#....#O#OO.O..#.OOOOO.....O...O. +O#.#..#..OO...O..OO.#...#..........#OO#.#..O.#...##O...#..O.O....#.O....#..##.#.#.#O.#...#..#...O#.. +.#..#OO.....O..O....O........O#.O.OO....##....OO....O##O..##.#O..O#O##.O.O.O#..OO.....O#.#.........# +O.O.#..#O...O..O..O....O.....#OOO.O.......O#.OO..O.....#O...O#...O...O......#.#.#....#..#OO.#OOO...# +.O.....O..#O.##OO..#OOOO..#O.O.#O....OO#OOO....O....OO...O........#..O...O...O....#.O#O.O.#O.#.O.O.. +........O.O.......O...OO...###..OO.O.....OO.O..#...#OO..#....O#......##.........#.#...#.O.O....#.... +.O.....##..O..#OO#OO.##...#O..#.OO..#..O.#O......#O..............O.....O.O.#O.O..#O.O...O.OO.O#..#O. +O..#.#......O#..OO..#......O.O.OOO.O...O.#....#....O#...O....##..#.....O..#....O#OOO....O.O..O...... +.....O.O.....O.#..O...#O#.O..O#O..#O..##...O.#..O........O.#.O.O......OO.#....O.#.#.O..O....O#....#. +..#......#OO.O.#.#..OO...#.#..O.#....O#.#O.OOO....O###......#....O.##..O..#.O.#.#.O......O#.OO....#O +#..O...OOO..O....OO.O..#..O.OO.#OO.OOO#....OO#......OO.O....O.OO..##.O.#..O...#.#.......O.....#..O.. +#..#O..O.O...#......O##.O.#......#..O##....#O####OO.#.##.O#.O.#.#...#.OO....O...#O....OO#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..###O.O..#O..##..#.#...#OO.........O#.....##....#O..#...O...#...#...OO...O..O +..OOO..O..#OOO.O.#..#......#....OO.........O.#.O...O#......O.O...##.#..#.OO#O.....O......#........#. +O.#O....O..O..O.......O..........#..OO#OO.O...#.O#.O....O..........O.....#.##..#..##.O#O....O.O...#. +.#.OO##......O#.O..#...O..O...##..##O..#O....#..#...O...O...#.##...#.OO##O..........#O....O....#.O.O +..O#....OOO...O#...#.....OO##..#.O.O.O..O...OOO....#.#...........OO.O#.O.#O..#..O#O#O....#..#.O..... +....#.#O.#OO..#.....#.OO.#.O..O.O.###O.O..#.#O...O..#...#..O......O...#....#..OO..........##........ +......O.O..O.O..O.#.......OO.OO..##.O...........O#OO.O#.#OO.OO.......#.OO#..###O.O.........#.#O#.O.# +.OOO..#.O#O....O..#.......O...#..#.....OO...O............#O...OO........#O##.#.O.#.#.O....O#.O.OOOO. +..O..O.###OO..O.........OO.OO...#O..#...#OO.#..OO....O..O.O...O.O.....OO........#.##..#.......OO.... +..OO..#O...O.O..O...O.O.O....#.O##....#..O.O..OO..#.O#..O........O.#..#......OO#O.O.O..#......##.... +...O.....OO..O.OOO........O.#..OO...#........#.#...O.##O.O.O.#.#O.O...O.OOO..OO......O...#.#..O#O#.. +O#...OO...O...O....O..#....#O..#...........O..........O.O..##....O..#OO.O.#........#.OO..##....OO..O +...#....#.....OOOO..#O..#...O...OO.#...OO#...##..#.#....O...O#.OO...##..O.O#...O.....#..O.OO...O..O. +#..#.O.##.O..O.O...OOO.......###..#...O.OO....#O#.....#O#O.OO..O.....#.##.#..O.#...O.OOO...O#O..O... +.OO#.......O.....##.##..#...##O..OO#O.OO.O..O...O...OO#O...#..#...O...#..#...#O..#......OO.O.....O.. +O....#..OO.#...#......O.......O..OO#..O##....OO.#.#.#......#O..OO.O..O...#..#.O..O.OO##.O....O#..O.. +#...#.#..#....OO...O.#..OO..O..#..#..#.O.O....#.O.O.OO.O.#.O..#.....#.#..O...#.#...#O...OO.O#.O....O +...O.#.O.....#O.OO..O..##....#O...OO........#..O..#O...O...#...#..O..O....OO..#.O.O..OO...OO...OOO#. +........#...#.##O.#..#..#......O...........O..O#.O..OO..#..O.O..#OO#......O...#.....#.##O..#....O... +.......OO#...O.O..OOO.O#O..#..#...O.O..#..#O.O.O.#..........#..#.OO...#OOOO..OO#O.O....#.O...O....O. +..OO.O..O#.O.##...O..#O....O...O.#....#O#.O..OOO.O.O.O...O.O.#.O....#.....#.O...........O...O....#.. +#....OOO....O...OO#..#..O......O#...O..O#.##.#O...O.O#..........O.#.##...........#O....OO.O#O...#.## +.#......OO.O.OO#.#.#O.#O.......O..O..#......OO..#.O.O......O..O.O.O.......#O..OO....O..#.......OO.#. +...####OO...O..O..#.....#..O....O........##.O....#...#.O.OO##..#......OO.O.#....##...#..O...O.O..O#. +.....O....O.#..O.OO##...OOO#....#O#.....O#...O.O.#.O...OOO#.O.......O......OO.#..............O.#O#.. +...........O..#...#OOOO....OO.##....O.O.....O..O....O...O#.....#.O.O..O....O#..#..........#O.O....O. +.#O.O...#..#......O...........#.O.....##O...OO.O.OOO..OO...O.OO#.....OO#.OO.....#O#..#O#.O.O.#..#O.. +#...O..#..#.O.....O.O.#.#..#...O#..#..#O..#.....OO#.#.OO#.....O#...O.OO.............O#OOO..O.O..O.O. +.......O#O.O.#....#...........O.............O..#..OO#......OO.O...O..........OO.#..OO#O#.O##O#..O.O. +#.#......O.....OOOOO.O#O#...#.O....#...#..O#.#O....O.O#OO....#..O.O.#.#...##.OO.#.OO#.###O.....#..O. +OO...O.#............#.#.#...#..OO......#..O.#......##..OO....OO.#.OO...O..........O.#..O.#O###.O...O +##O###.OO.#.......O.O####....O.O..O.O#..#O.O.##O#......#O.##...O..#.#O..###..#.....#...#...O#....OO. +.#....O.##...O......O###........O....#.O#....#.O.#..........#.O.O.OOOO.......###...O....O......O.... +...O..#...#..O.#O......#O#..O.....O....O..#...##.OOOO.OOOO#..O.#..#.......#.#O#..#..#.OO#..#.#....O# +..OO.......O#.OOOO....O..#...O.#O#....##.........#O#OO#O#..#.##.......O.O......#.....#..O.O.#O.....# +#.O........O..O.#..#.O#O...#O#........O#.O#O..O.............#OO#..O#OOO..#O###..OOO...#.O........##. +....OO.......#.O..O.O........O#.#..O.O..OO.....O....O...O#.#....O.#O#.........#....OO#O#.#OO...#.#O. +.O.O..O.......#.OO..#...O.O#.O.#.O......#.O...OOO......O.O.O.#.OO#O.O.O...O#..#.O#.#..##.O.O...O.... +O..#O#O.O#.#...#..O............#O.OO...O..O...OOO##.O..O#...#.O..O#..O.O...##O.OO##O..#..OO#.OO..#OO +...#.O.......O.#.O..O.O.......O...##O...OO.#....O..O.........O.O...#.O..OO...O.O.O....O...#..#.#.OO. +OO.#...OO.#.O.....O....O..##O#O..O.OO#O....O..O.O..#.O.OO..O.O#.#.......O..O.....O.##....O.O..#.O... +#..O.#OO......##..#O.#...#...........O.##...#O...O.#..#..O..O..#...........O...OO.O...O#.........OO# +...O..OO....##.##O..O.##......#O.O#.OO..O#..OOO.OO.##OOO.#O..O.....O....O......#O...O.#.O........OO. +O.O.......OO#..O..#..O.###O...O.#...#O#O..#.#O#O.O..#O#...#.OO...O.....#.#.#O#..O.O#....O.O#..#O..O# +.#...O.###....#.......O....#...OO.....O.#.#.#.....O.#.......O..#.##.O..O#O..OO..OO..#O#......#O.#.#. +O.#.O..#O.......#.....#O#.....O.O#.......O#O.O#..##..OO.O.#..O.O..O....O...#O.O...#...##..O........O +...O........#.....O.###..O.O.O..#......O.#.....#O.O.#...O#..O#......#.O...#OO#....#O.O#......O..O#.# +O...O...OO.##.#.OO#.#OOO.#.O.O.##.O#....#..O.O#O.#..#.....OO..#O...O.O.........O...#.O...O.#...O..OO +..#...OO.#..##.O.O..O.O...O##....#.O..O.OO#...OO.O.....O...#.O.##OO.O.O.OO....#.O.O###..O#..#...O..# +..#..O.O.....O..O.....O.....OO...##.#...#..##.#..O#O.....##...O.#O...O.O.#O..#....#...OO..#..O...#O# +......#.O....O.........O..O...#.##....OO.O...#........#...#..O.O#....#.##.#.O##.O.#.......OO.....O#. +.O....O.....O.O..O..#...O......##..#.OO.#.........#...O.#.#.....O..O..O..O..OO...O..O#.##O...#.O.... +....O.#.#.#.#.........O.#...#......#...#.#O#.O.O#....#...O#....O.O#O.......O#.......#O...O..O..#.O#O +...O......OO.......#O.O.#...OO.......O.........##O.......O.......#..##....##.#.#O.#O....##....#....O +....O...#OO..O..O...#.....O.#O..OO#......O#OO..#....O....OOO.O.O....#..O.#...O#........O...O.#.#O... +.O....O....OO...O......##...#O.....#...O......O....O.##OO.......#....O....O....O.O...##O...#.OO..... +#OO.O..#..O.O##...#..#.O.O..O#O.#.......O.#O..O..O.....O.......O#...O...O.........##..OO#..O.O#.##.. +O.#O####...#O.O#.#OO..#O..O....OO.#O#....O........O..#.#OO.....O...O...O.......#.O#..O..#.#O.O..#.O. +O.#.....#.#.....#........O#...##O....#....O..O.O.....O#O.OO..........O..##O.O...O...#.....#....O.O.. +....#OO#.#O...O###.O.#..#...O....O.........O.#...OO#.....#....O..##...O..##O......OO.O#..........OO. +O....O...O#O...#.#O...#.OO...O.....#O#.O..OOO#.OO.....#...#O#....O#..O##..O.O.#O#O###.OO....O...O#.. +#...O..O##..#O.O#OO....#O...#.O#...##...O#......O.#...#....O#....O.....OOO#....O..#O#.O#O....O.#O... +#.O....##O.#.OOO..O#.O..##O#O.#O#..#.....O....##...#..O........#.O....O..#.....##.#.......#OO...#O.. +...O.....#.....#.#....O.........O.....#O....O..OO.....#O.#....#...#.#O.O...#OO#.............O.O#..O# +..#O..#..#.......#....#.#.......#O..#O#....O.#O.#......#.#...#O........O.....O.#..##..O#.##...#OO... +.O.#...#.O.O......OOOOO..O.#O...O#O.#####...#..O#....O....#...O.##..#O......O..###O.#........#.O.... +....##.#..O........O#O.#O#..#.....O#O.O#.....#.....#........OO.....#....O..#.O....O.#O.O.O...#.##..# +..#..O.#O#..O...O.O.............O.....#..OOO...#O#..O...#..##...O...O........#....#..O.O...##.OO..## +..OO#.O..O.....O...O.##...OO.O...O....#..O.#O.......#.#O#.OO.......#.#...O..#......O..##..##.O..O#O. \ No newline at end of file diff --git a/adventofcode/src/test/resources/org/ck/adventofcode/year2023/day14/01a.result.txt b/adventofcode/src/test/resources/org/ck/adventofcode/year2023/day14/01a.result.txt new file mode 100644 index 00000000..d55f9f74 --- /dev/null +++ b/adventofcode/src/test/resources/org/ck/adventofcode/year2023/day14/01a.result.txt @@ -0,0 +1 @@ +136 \ No newline at end of file diff --git a/adventofcode/src/test/resources/org/ck/adventofcode/year2023/day14/01a.txt b/adventofcode/src/test/resources/org/ck/adventofcode/year2023/day14/01a.txt new file mode 100644 index 00000000..b92d1a30 --- /dev/null +++ b/adventofcode/src/test/resources/org/ck/adventofcode/year2023/day14/01a.txt @@ -0,0 +1,10 @@ +O....#.... +O.OO#....# +.....##... +OO.#O....O +.O.....O#. +O.#..O.#.# +..O..#O..O +.......O.. +#....###.. +#OO..#.... \ No newline at end of file diff --git a/adventofcode/src/test/resources/org/ck/adventofcode/year2023/day14/02.result.txt b/adventofcode/src/test/resources/org/ck/adventofcode/year2023/day14/02.result.txt new file mode 100644 index 00000000..7024319d --- /dev/null +++ b/adventofcode/src/test/resources/org/ck/adventofcode/year2023/day14/02.result.txt @@ -0,0 +1 @@ +118747 \ No newline at end of file diff --git a/adventofcode/src/test/resources/org/ck/adventofcode/year2023/day14/02.txt b/adventofcode/src/test/resources/org/ck/adventofcode/year2023/day14/02.txt new file mode 100644 index 00000000..415085f0 --- /dev/null +++ b/adventofcode/src/test/resources/org/ck/adventofcode/year2023/day14/02.txt @@ -0,0 +1,100 @@ +O.O#....O.O...O..OO#OO##..O..##...#..........OO..#.OO...................O..O##.#OOO...O#.#.#.O.O#OO. +.O..OO..O.O..O......OO.#....#O#.#.#.#.#.O.OO...#.O#.OOO.#.#.#.OO..#.#O...O.O.O.O#.#.O.O....#..O#O... +O....#..O..O.OO..#OO.O.....O#OOO..#.#......O...#..#..O......#O.#.O.#.O...#.#.#.........O#.......#OO. +......O.O##......###OO#..O#.#...O...O.....##.........#.OO.#........#OO.O....###...#.##..O........O.# +#.OO.....OOO....O.....OO.OOO..#O.OO...#...O......OO###........O..#.#.O..O......O#...O.....#.#...##.. +#..O.#..OO.OO.O.OOO#O...O......O..#O..O#.O.O.O#....O.#O.O.....#..#..O.O.#O..O....O#.O..#....O#...... +#..O#...O.O.O..O...#.O.#.O..........O.#.#.........O.......##...#..O.OO#......#.......O.#.#..#.OO##O. +O.O..O..#......#....#O....O..O#.OOO..#..O#.OO#.........O..##...O..#.........O##...O....O..O.O.O..O.. +O.O#.O...OO....O....##O.O......O.O..O....#...O...O##........#.......#....O..O.......O...#O.....#.... +..O.#..#..OO.O..#...#..O#OOO..#.O.#O#OOO....#..OOO.#O..O..#.OOOO.........O#..O..O...O.##..O......#.. +##..#..#.....O..OO###.........##..##..OO...#..#O.#......#O...O.....#........#....OO.#OO.#.O....#.O#O +.O.....O.O.O....#OO..O.##OO#..O.....O..#..O..#....O..O#....O..#.OO..O....OO..O.O..O#.....O.O.#O..OO. +O#O.##O#..................O.OO...#...#..#O....O..O..OO#.O#...##.O...##.OO#.....O.#.#...##..O.OO..O.. +O.....OO..OO..#OO#.....O.O.#....OO.#...###.......O#...##....##.O..##......#......O#O..OO.OO....O.... +.......O.O.#..O..O.#.O..O.O#O.#....##.OO.#...#.OO#..O...#..O...O...#.#...O#.....O#O........O...##.#O +#....O..O..OOO...#....#.##.#....O.............##O#...#..O.O.##..#.O..O.#...#.O.##O..##.#...O......## +.O...##.O.....#OO.O..O..#O.#.#...O....#...#...O..#O...........##..OO##...#...#..O#O.........O..#..#O +O...O...O..#..#OO.....OOO.#.........O..O.......#.#.#...OO##..O...O.....O#.#..O........#.#.O.O..##.#. +.###...#.....#..#O.O.......O.....O#.OO....##.OO.........O#...OO.OO#.#....#O#OO.O..#.OOOOO.....O...O. +O#.#..#..OO...O..OO.#...#..........#OO#.#..O.#...##O...#..O.O....#.O....#..##.#.#.#O.#...#..#...O#.. +.#..#OO.....O..O....O........O#.O.OO....##....OO....O##O..##.#O..O#O##.O.O.O#..OO.....O#.#.........# +O.O.#..#O...O..O..O....O.....#OOO.O.......O#.OO..O.....#O...O#...O...O......#.#.#....#..#OO.#OOO...# +.O.....O..#O.##OO..#OOOO..#O.O.#O....OO#OOO....O....OO...O........#..O...O...O....#.O#O.O.#O.#.O.O.. +........O.O.......O...OO...###..OO.O.....OO.O..#...#OO..#....O#......##.........#.#...#.O.O....#.... +.O.....##..O..#OO#OO.##...#O..#.OO..#..O.#O......#O..............O.....O.O.#O.O..#O.O...O.OO.O#..#O. +O..#.#......O#..OO..#......O.O.OOO.O...O.#....#....O#...O....##..#.....O..#....O#OOO....O.O..O...... +.....O.O.....O.#..O...#O#.O..O#O..#O..##...O.#..O........O.#.O.O......OO.#....O.#.#.O..O....O#....#. +..#......#OO.O.#.#..OO...#.#..O.#....O#.#O.OOO....O###......#....O.##..O..#.O.#.#.O......O#.OO....#O +#..O...OOO..O....OO.O..#..O.OO.#OO.OOO#....OO#......OO.O....O.OO..##.O.#..O...#.#.......O.....#..O.. +#..#O..O.O...#......O##.O.#......#..O##....#O####OO.#.##.O#.O.#.#...#.OO....O...#O....OO#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..###O.O..#O..##..#.#...#OO.........O#.....##....#O..#...O...#...#...OO...O..O +..OOO..O..#OOO.O.#..#......#....OO.........O.#.O...O#......O.O...##.#..#.OO#O.....O......#........#. +O.#O....O..O..O.......O..........#..OO#OO.O...#.O#.O....O..........O.....#.##..#..##.O#O....O.O...#. +.#.OO##......O#.O..#...O..O...##..##O..#O....#..#...O...O...#.##...#.OO##O..........#O....O....#.O.O +..O#....OOO...O#...#.....OO##..#.O.O.O..O...OOO....#.#...........OO.O#.O.#O..#..O#O#O....#..#.O..... +....#.#O.#OO..#.....#.OO.#.O..O.O.###O.O..#.#O...O..#...#..O......O...#....#..OO..........##........ +......O.O..O.O..O.#.......OO.OO..##.O...........O#OO.O#.#OO.OO.......#.OO#..###O.O.........#.#O#.O.# +.OOO..#.O#O....O..#.......O...#..#.....OO...O............#O...OO........#O##.#.O.#.#.O....O#.O.OOOO. +..O..O.###OO..O.........OO.OO...#O..#...#OO.#..OO....O..O.O...O.O.....OO........#.##..#.......OO.... +..OO..#O...O.O..O...O.O.O....#.O##....#..O.O..OO..#.O#..O........O.#..#......OO#O.O.O..#......##.... +...O.....OO..O.OOO........O.#..OO...#........#.#...O.##O.O.O.#.#O.O...O.OOO..OO......O...#.#..O#O#.. +O#...OO...O...O....O..#....#O..#...........O..........O.O..##....O..#OO.O.#........#.OO..##....OO..O +...#....#.....OOOO..#O..#...O...OO.#...OO#...##..#.#....O...O#.OO...##..O.O#...O.....#..O.OO...O..O. +#..#.O.##.O..O.O...OOO.......###..#...O.OO....#O#.....#O#O.OO..O.....#.##.#..O.#...O.OOO...O#O..O... +.OO#.......O.....##.##..#...##O..OO#O.OO.O..O...O...OO#O...#..#...O...#..#...#O..#......OO.O.....O.. +O....#..OO.#...#......O.......O..OO#..O##....OO.#.#.#......#O..OO.O..O...#..#.O..O.OO##.O....O#..O.. +#...#.#..#....OO...O.#..OO..O..#..#..#.O.O....#.O.O.OO.O.#.O..#.....#.#..O...#.#...#O...OO.O#.O....O +...O.#.O.....#O.OO..O..##....#O...OO........#..O..#O...O...#...#..O..O....OO..#.O.O..OO...OO...OOO#. +........#...#.##O.#..#..#......O...........O..O#.O..OO..#..O.O..#OO#......O...#.....#.##O..#....O... +.......OO#...O.O..OOO.O#O..#..#...O.O..#..#O.O.O.#..........#..#.OO...#OOOO..OO#O.O....#.O...O....O. +..OO.O..O#.O.##...O..#O....O...O.#....#O#.O..OOO.O.O.O...O.O.#.O....#.....#.O...........O...O....#.. +#....OOO....O...OO#..#..O......O#...O..O#.##.#O...O.O#..........O.#.##...........#O....OO.O#O...#.## +.#......OO.O.OO#.#.#O.#O.......O..O..#......OO..#.O.O......O..O.O.O.......#O..OO....O..#.......OO.#. +...####OO...O..O..#.....#..O....O........##.O....#...#.O.OO##..#......OO.O.#....##...#..O...O.O..O#. +.....O....O.#..O.OO##...OOO#....#O#.....O#...O.O.#.O...OOO#.O.......O......OO.#..............O.#O#.. +...........O..#...#OOOO....OO.##....O.O.....O..O....O...O#.....#.O.O..O....O#..#..........#O.O....O. +.#O.O...#..#......O...........#.O.....##O...OO.O.OOO..OO...O.OO#.....OO#.OO.....#O#..#O#.O.O.#..#O.. +#...O..#..#.O.....O.O.#.#..#...O#..#..#O..#.....OO#.#.OO#.....O#...O.OO.............O#OOO..O.O..O.O. +.......O#O.O.#....#...........O.............O..#..OO#......OO.O...O..........OO.#..OO#O#.O##O#..O.O. +#.#......O.....OOOOO.O#O#...#.O....#...#..O#.#O....O.O#OO....#..O.O.#.#...##.OO.#.OO#.###O.....#..O. +OO...O.#............#.#.#...#..OO......#..O.#......##..OO....OO.#.OO...O..........O.#..O.#O###.O...O +##O###.OO.#.......O.O####....O.O..O.O#..#O.O.##O#......#O.##...O..#.#O..###..#.....#...#...O#....OO. +.#....O.##...O......O###........O....#.O#....#.O.#..........#.O.O.OOOO.......###...O....O......O.... +...O..#...#..O.#O......#O#..O.....O....O..#...##.OOOO.OOOO#..O.#..#.......#.#O#..#..#.OO#..#.#....O# +..OO.......O#.OOOO....O..#...O.#O#....##.........#O#OO#O#..#.##.......O.O......#.....#..O.O.#O.....# +#.O........O..O.#..#.O#O...#O#........O#.O#O..O.............#OO#..O#OOO..#O###..OOO...#.O........##. +....OO.......#.O..O.O........O#.#..O.O..OO.....O....O...O#.#....O.#O#.........#....OO#O#.#OO...#.#O. +.O.O..O.......#.OO..#...O.O#.O.#.O......#.O...OOO......O.O.O.#.OO#O.O.O...O#..#.O#.#..##.O.O...O.... +O..#O#O.O#.#...#..O............#O.OO...O..O...OOO##.O..O#...#.O..O#..O.O...##O.OO##O..#..OO#.OO..#OO +...#.O.......O.#.O..O.O.......O...##O...OO.#....O..O.........O.O...#.O..OO...O.O.O....O...#..#.#.OO. +OO.#...OO.#.O.....O....O..##O#O..O.OO#O....O..O.O..#.O.OO..O.O#.#.......O..O.....O.##....O.O..#.O... +#..O.#OO......##..#O.#...#...........O.##...#O...O.#..#..O..O..#...........O...OO.O...O#.........OO# +...O..OO....##.##O..O.##......#O.O#.OO..O#..OOO.OO.##OOO.#O..O.....O....O......#O...O.#.O........OO. +O.O.......OO#..O..#..O.###O...O.#...#O#O..#.#O#O.O..#O#...#.OO...O.....#.#.#O#..O.O#....O.O#..#O..O# +.#...O.###....#.......O....#...OO.....O.#.#.#.....O.#.......O..#.##.O..O#O..OO..OO..#O#......#O.#.#. +O.#.O..#O.......#.....#O#.....O.O#.......O#O.O#..##..OO.O.#..O.O..O....O...#O.O...#...##..O........O +...O........#.....O.###..O.O.O..#......O.#.....#O.O.#...O#..O#......#.O...#OO#....#O.O#......O..O#.# +O...O...OO.##.#.OO#.#OOO.#.O.O.##.O#....#..O.O#O.#..#.....OO..#O...O.O.........O...#.O...O.#...O..OO +..#...OO.#..##.O.O..O.O...O##....#.O..O.OO#...OO.O.....O...#.O.##OO.O.O.OO....#.O.O###..O#..#...O..# +..#..O.O.....O..O.....O.....OO...##.#...#..##.#..O#O.....##...O.#O...O.O.#O..#....#...OO..#..O...#O# +......#.O....O.........O..O...#.##....OO.O...#........#...#..O.O#....#.##.#.O##.O.#.......OO.....O#. +.O....O.....O.O..O..#...O......##..#.OO.#.........#...O.#.#.....O..O..O..O..OO...O..O#.##O...#.O.... +....O.#.#.#.#.........O.#...#......#...#.#O#.O.O#....#...O#....O.O#O.......O#.......#O...O..O..#.O#O +...O......OO.......#O.O.#...OO.......O.........##O.......O.......#..##....##.#.#O.#O....##....#....O +....O...#OO..O..O...#.....O.#O..OO#......O#OO..#....O....OOO.O.O....#..O.#...O#........O...O.#.#O... +.O....O....OO...O......##...#O.....#...O......O....O.##OO.......#....O....O....O.O...##O...#.OO..... +#OO.O..#..O.O##...#..#.O.O..O#O.#.......O.#O..O..O.....O.......O#...O...O.........##..OO#..O.O#.##.. +O.#O####...#O.O#.#OO..#O..O....OO.#O#....O........O..#.#OO.....O...O...O.......#.O#..O..#.#O.O..#.O. +O.#.....#.#.....#........O#...##O....#....O..O.O.....O#O.OO..........O..##O.O...O...#.....#....O.O.. +....#OO#.#O...O###.O.#..#...O....O.........O.#...OO#.....#....O..##...O..##O......OO.O#..........OO. +O....O...O#O...#.#O...#.OO...O.....#O#.O..OOO#.OO.....#...#O#....O#..O##..O.O.#O#O###.OO....O...O#.. +#...O..O##..#O.O#OO....#O...#.O#...##...O#......O.#...#....O#....O.....OOO#....O..#O#.O#O....O.#O... +#.O....##O.#.OOO..O#.O..##O#O.#O#..#.....O....##...#..O........#.O....O..#.....##.#.......#OO...#O.. +...O.....#.....#.#....O.........O.....#O....O..OO.....#O.#....#...#.#O.O...#OO#.............O.O#..O# +..#O..#..#.......#....#.#.......#O..#O#....O.#O.#......#.#...#O........O.....O.#..##..O#.##...#OO... +.O.#...#.O.O......OOOOO..O.#O...O#O.#####...#..O#....O....#...O.##..#O......O..###O.#........#.O.... +....##.#..O........O#O.#O#..#.....O#O.O#.....#.....#........OO.....#....O..#.O....O.#O.O.O...#.##..# +..#..O.#O#..O...O.O.............O.....#..OOO...#O#..O...#..##...O...O........#....#..O.O...##.OO..## +..OO#.O..O.....O...O.##...OO.O...O....#..O.#O.......#.#O#.OO.......#.#...O..#......O..##..##.O..O#O. \ No newline at end of file diff --git a/adventofcode/src/test/resources/org/ck/adventofcode/year2023/day14/02a.result.txt b/adventofcode/src/test/resources/org/ck/adventofcode/year2023/day14/02a.result.txt new file mode 100644 index 00000000..4b6f9c39 --- /dev/null +++ b/adventofcode/src/test/resources/org/ck/adventofcode/year2023/day14/02a.result.txt @@ -0,0 +1 @@ +64 \ No newline at end of file diff --git a/adventofcode/src/test/resources/org/ck/adventofcode/year2023/day14/02a.txt b/adventofcode/src/test/resources/org/ck/adventofcode/year2023/day14/02a.txt new file mode 100644 index 00000000..b92d1a30 --- /dev/null +++ b/adventofcode/src/test/resources/org/ck/adventofcode/year2023/day14/02a.txt @@ -0,0 +1,10 @@ +O....#.... +O.OO#....# +.....##... +OO.#O....O +.O.....O#. +O.#..O.#.# +..O..#O..O +.......O.. +#....###.. +#OO..#.... \ No newline at end of file