From c3350982cbbef734db65cf8c5d9c5c4cda2a9f6e Mon Sep 17 00:00:00 2001 From: Burnus Date: Thu, 14 Dec 2023 16:09:52 +0100 Subject: [PATCH] Added Solution for 2023 day 14 --- .../day14_parabolic_reflector_dish/Cargo.toml | 15 ++ .../challenge.txt | 125 +++++++++++ .../day14_parabolic_reflector_dish/src/lib.rs | 207 ++++++++++++++++++ .../tests/challenge_input | 100 +++++++++ .../tests/sample_input | 10 + 5 files changed, 457 insertions(+) create mode 100644 2023/day14_parabolic_reflector_dish/Cargo.toml create mode 100644 2023/day14_parabolic_reflector_dish/challenge.txt create mode 100644 2023/day14_parabolic_reflector_dish/src/lib.rs create mode 100644 2023/day14_parabolic_reflector_dish/tests/challenge_input create mode 100644 2023/day14_parabolic_reflector_dish/tests/sample_input diff --git a/2023/day14_parabolic_reflector_dish/Cargo.toml b/2023/day14_parabolic_reflector_dish/Cargo.toml new file mode 100644 index 0000000..8da9c35 --- /dev/null +++ b/2023/day14_parabolic_reflector_dish/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "day14_parabolic_reflector_dish" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] + +[dev-dependencies] +criterion = "0.5.1" + +[[bench]] +name = "test_benchmark" +harness = false diff --git a/2023/day14_parabolic_reflector_dish/challenge.txt b/2023/day14_parabolic_reflector_dish/challenge.txt new file mode 100644 index 0000000..b1af0e7 --- /dev/null +++ b/2023/day14_parabolic_reflector_dish/challenge.txt @@ -0,0 +1,125 @@ +You reach the place where all of the mirrors were pointing: a massive [parabolic reflector dish](https://en.wikipedia.org/wiki/Parabolic_reflector) attached to the side of another large mountain. + +The dish is made up of many small mirrors, but while the mirrors themselves are roughly in the shape of a parabolic reflector dish, each individual mirror seems to be pointing in slightly the wrong direction. If the dish is meant to focus light, all it's doing right now is sending it in a vague direction. + +This system must be what provides the energy for the lava! If you focus the reflector dish, maybe you can go where it's pointing and use the light to fix the lava production. + +Upon closer inspection, the individual mirrors each appear to be connected via an elaborate system of ropes and pulleys to a large metal platform below the dish. The platform is covered in large rocks of various shapes. Depending on their position, the weight of the rocks deforms the platform, and the shape of the platform controls which ropes move and ultimately the focus of the dish. + +In short: if you move the rocks, you can focus the dish. The platform even has a control panel on the side that lets you *tilt* it in one of four directions! The rounded rocks (`O`) will roll when the platform is tilted, while the cube-shaped rocks (`#`) will stay in place. You note the positions of all of the empty spaces (`.`) and rocks (your puzzle input). For example: + +``` +O....#.... +O.OO#....# +.....##... +OO.#O....O +.O.....O#. +O.#..O.#.# +..O..#O..O +.......O.. +#....###.. +#OO..#.... + +``` + +Start by tilting the lever so all of the rocks will slide *north* as far as they will go: + +``` +OOOO.#.O.. +OO..#....# +OO..O##..O +O..#.OO... +........#. +..#....#.# +..O..#.O.O +..O....... +#....###.. +#....#.... + +``` + +You notice that the support beams along the north side of the platform are *damaged*; to ensure the platform doesn't collapse, you should calculate the *total load* on the north support beams. + +The amount of load caused by a single rounded rock (`O`) is equal to the number of rows from the rock to the south edge of the platform, including the row the rock is on. (Cube-shaped rocks (`#`) don't contribute to load.) So, the amount of load caused by each rock in each row is as follows: + +``` +OOOO.#.O.. 10 +OO..#....# 9 +OO..O##..O 8 +O..#.OO... 7 +........#. 6 +..#....#.# 5 +..O..#.O.O 4 +..O....... 3 +#....###.. 2 +#....#.... 1 + +``` + +The total load is the sum of the load caused by all of the *rounded rocks*. In this example, the total load is `*136*`. + +Tilt the platform so that the rounded rocks all roll north. Afterward, *what is the total load on the north support beams?* + +Your puzzle answer was `108935`. + +\--- Part Two --- +---------- + +The parabolic reflector dish deforms, but not in a way that focuses the beam. To do that, you'll need to move the rocks to the edges of the platform. Fortunately, a button on the side of the control panel labeled "*spin cycle*" attempts to do just that! + +Each *cycle* tilts the platform four times so that the rounded rocks roll *north*, then *west*, then *south*, then *east*. After each tilt, the rounded rocks roll as far as they can before the platform tilts in the next direction. After one cycle, the platform will have finished rolling the rounded rocks in those four directions in that order. + +Here's what happens in the example above after each of the first few cycles: + +``` +After 1 cycle: +.....#.... +....#...O# +...OO##... +.OO#...... +.....OOO#. +.O#...O#.# +....O#.... +......OOOO +#...O###.. +#..OO#.... + +After 2 cycles: +.....#.... +....#...O# +.....##... +..O#...... +.....OOO#. +.O#...O#.# +....O#...O +.......OOO +#..OO###.. +#.OOO#...O + +After 3 cycles: +.....#.... +....#...O# +.....##... +..O#...... +.....OOO#. +.O#...O#.# +....O#...O +.......OOO +#...O###.O +#.OOO#...O + +``` + +This process should work if you leave it running long enough, but you're still worried about the north support beams. To make sure they'll survive for a while, you need to calculate the *total load* on the north support beams after `1000000000` cycles. + +In the above example, after `1000000000` cycles, the total load on the north support beams is `*64*`. + +Run the spin cycle for `1000000000` cycles. Afterward, *what is the total load on the north support beams?* + +Your puzzle answer was `100876`. + +Both parts of this puzzle are complete! They provide two gold stars: \*\* + +At this point, you should [return to your Advent calendar](/2023) and try another puzzle. + +If you still want to see it, you can [get your puzzle input](14/input). \ No newline at end of file diff --git a/2023/day14_parabolic_reflector_dish/src/lib.rs b/2023/day14_parabolic_reflector_dish/src/lib.rs new file mode 100644 index 0000000..77c98e8 --- /dev/null +++ b/2023/day14_parabolic_reflector_dish/src/lib.rs @@ -0,0 +1,207 @@ +use core::fmt::Display; +use std::collections::HashMap; + +#[derive(Debug, PartialEq, Eq)] +pub enum ParseError { + InvalidChar(char), +} + +impl Display for ParseError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::InvalidChar(c) => write!(f, "Encountered \'{c}\', which is not a valid item"), + } + } +} + +#[derive(PartialEq)] +enum Direction { North, South, West, East } + +struct Platform { + rounded_rocks: Vec<(usize, usize)>, + cuboid_rocks: Vec<(usize, usize)>, +} + +impl TryFrom<&str> for Platform { + type Error = ParseError; + + fn try_from(value: &str) -> Result { + let y_max = value.lines().count() + 1; + let mut x_max = 2; + let mut rounded_rocks = Vec::new(); + let mut cuboid_rocks = Vec::from([(0, 0)]); + for (line_idx, line) in value.lines().enumerate() { + x_max = x_max.max(line.len() + 1); + for (char_idx, c) in line.chars().enumerate() { + match c { + 'O' => rounded_rocks.push((line_idx+1, char_idx+1)), + '#' => cuboid_rocks.push((line_idx+1, char_idx+1)), + '.' => (), + e => return Err(Self::Error::InvalidChar(e)), + } + } + } + cuboid_rocks.push((y_max, x_max)); + + Ok(Platform { rounded_rocks, cuboid_rocks }) + } +} + +impl Platform { + fn tilt(&mut self, direction: Direction) { + // sort the rocks such that colliding rocks are adjacent in the Vec + let sort_order = match direction { + Direction::North => |(y1, x1): &(usize, usize), (y2, x2): &(usize, usize)| x1.cmp(x2).then_with(|| y1.cmp(y2)), + Direction::South => |(y1, x1): &(usize, usize), (y2, x2): &(usize, usize)| x1.cmp(x2).then_with(|| y2.cmp(y1)), + Direction::West => |(y1, x1): &(usize, usize), (y2, x2): &(usize, usize)| y1.cmp(y2).then_with(|| x1.cmp(x2)), + Direction::East => |(y1, x1): &(usize, usize), (y2, x2): &(usize, usize)| y1.cmp(y2).then_with(|| x2.cmp(x1)), + }; + self.rounded_rocks.sort_by(sort_order); + self.cuboid_rocks.sort_by(sort_order); + + // Convenience closure that gives us the coordinates in order: (perpendicular to tilt + // direction, in tilt direction), so that only objects with the same major coordinate can + // collide. + let major_minor = |(y, x): (usize, usize)| -> (usize, usize) { + match direction { + Direction::North | Direction::South => (x, y), + Direction::West | Direction::East => (y, x), + } + }; + // Convenience closure that tells us wether the cuboid rock would be before this rounded + // rock if it were in the same Vec, that is: Its major coordinate is smaller, so it's in a + // path we already covered, or they are the same and its minor coordinate is such that the + // rounded rock will be tilted towards it. + let is_before = |(cuboid_major, cuboid_minor): (usize, usize), major: usize, minor: usize| -> bool { + cuboid_major < major || (major == cuboid_major && match direction { + Direction::North | Direction::West => minor > cuboid_minor, + Direction::South | Direction::East => minor < cuboid_minor, + }) + }; + let before_edge = match direction { + Direction::North | Direction::West => 1, + Direction::South | Direction::East => major_minor(*self.cuboid_rocks.last().unwrap()).1 - 1, + }; + + let mut last_major = 0; + let mut last_minor = 0; + let mut cuboid_idx = 0; + for rounded_rock in self.rounded_rocks.iter_mut() { + let (major, minor) = major_minor(*rounded_rock); + if last_major == major { + // The last rock we moved was in the same path as this one. Move just before it, if + // no cube shaped rock is in the way. + + // Find the first cube shaped rock after this rounded rock (see is_before + // for what that means) and then go one step back, so that we have the last + // cube shaped rock before this rounded rock. This is the only one that could + // potentially be relevant for us. + while is_before(major_minor(self.cuboid_rocks[cuboid_idx+1]), major, minor) { + cuboid_idx += 1; + } + let (cuboid_major, cuboid_minor) = major_minor(self.cuboid_rocks[cuboid_idx]); + + if cuboid_major == major { + // It is relevant. Move before it or the last rounded rock, whichever comes + // first. + last_minor = match direction { + Direction::North | Direction::West => last_minor.max(cuboid_minor) + 1, + Direction::South | Direction::East => last_minor.min(cuboid_minor) - 1, + }; + } else { + // It isn't relevant. Move before the last rounded rock. + last_minor = match direction { + Direction::North | Direction::West => last_minor + 1, + Direction::South | Direction::East => last_minor - 1, + }; + } + } else { + // The last rock was in a different path. Move until the edge, if no cube shaped + // rock is in the way. + + // Again, find the last cube shaped rock before this rounded rock, as above. + while is_before(major_minor(self.cuboid_rocks[cuboid_idx+1]), major, minor) { + cuboid_idx += 1; + } + let (cuboid_major, cuboid_minor) = major_minor(self.cuboid_rocks[cuboid_idx]); + + if cuboid_major == major { + // It is relevant. Move just before it. + last_minor = match direction { + Direction::North | Direction::West => cuboid_minor + 1, + Direction::South | Direction::East => cuboid_minor - 1, + }; + } else { + // It isn't relevant. Move just before the edge. + last_minor = before_edge; + } + last_major = major; + } + // Update the minor dimension of this rock in our Vec. + match direction { + Direction::North | Direction::South => rounded_rock.0 = last_minor, + Direction::West | Direction::East => rounded_rock.1 = last_minor, + }; + } + } + + fn spin(&mut self, cycle_count: usize) { + let mut mem: HashMap, usize> = HashMap::new(); + for idx in 1..=cycle_count { + self.tilt(Direction::North); + self.tilt(Direction::West); + self.tilt(Direction::South); + self.tilt(Direction::East); + if let Some(prev) = mem.get(&self.rounded_rocks) { + // We have already seen this arrangement, meaning we must be in a cycle with period + // (idx-prev). So we must have seen our target arrangement already, after prev+n + // steps, where + // (prev+n)%period == cycle_count%period. So: + // n = (cycle_count-prev)%period // n is equal to n%period, otherwise we wouldn't + // have encountered it yet. Such an n always + // exists. + // prev+n = prev + (cycle_count-prev)%period + self.rounded_rocks = mem.iter().find(|(_rounded_rocks, after)| **after == prev + (cycle_count-prev)%(idx-prev)).unwrap().0.to_vec(); + break; + } + else { + // This arrangement is new. Save it for later. + mem.insert(self.rounded_rocks.to_vec(), idx); + } + } + } +} + +pub fn run(input: &str) -> Result<(usize, usize), ParseError> { + let mut platform = Platform::try_from(input)?; + let y_max = platform.cuboid_rocks.last().unwrap().1; + platform.tilt(Direction::North); + let first = platform.rounded_rocks.iter().map(|(y, _x)| y_max - y).sum(); + // It doesn't matter that we already tilted north, since tilting twice in the same direction + // doesn't change anything. + platform.spin(1000000000); + let second = platform.rounded_rocks.iter().map(|(y, _x)| y_max - y).sum(); + Ok((first, second)) +} + +#[cfg(test)] +mod tests { + use super::*; + use std::fs::read_to_string; + + fn read_file(name: &str) -> String { + read_to_string(name).expect(&format!("Unable to read file: {name}")[..]).trim().to_string() + } + + #[test] + fn test_sample() { + let sample_input = read_file("tests/sample_input"); + assert_eq!(run(&sample_input), Ok((136, 64))); + } + + #[test] + fn test_challenge() { + let challenge_input = read_file("tests/challenge_input"); + assert_eq!(run(&challenge_input), Ok((108935, 100876))); + } +} diff --git a/2023/day14_parabolic_reflector_dish/tests/challenge_input b/2023/day14_parabolic_reflector_dish/tests/challenge_input new file mode 100644 index 0000000..a83b74f --- /dev/null +++ b/2023/day14_parabolic_reflector_dish/tests/challenge_input @@ -0,0 +1,100 @@ +...O.....#O#....O###...#..OOO.O#....#.O.O.....O...OO##.#..O.O...........O........#...#.#O........##. +#OO..O.##..#..........#.....O...##..O#.#O#O..##.....#.......O....##.#..#OO.O#O#....O..OO.O.....OO#.# +.###..O.#...O.#......O.#.......#.........#OO##.....#...#...O....#..O.O.O.#.O..O...##....O.O#.O....O. +O.O......OO.O#..#....O...#..##...O.#..##O.#...O.O....OO#......O...#...OO#O......O.....#O.O.#.#O.#O.. +.#....#.O#...O..O#..O.##..##.O..O...#...#....O#.#..OOO##..O#.#...#.#O.O#...#...O.O...#...O#O.###.... +.#.....O..#...#..#.##.OO.#O.#........................#...#OO.O.OO.##....O..#OOO#........O.....OO.#OO +O....#.O.#O#O..#...#O.O.OO#O.OO......O.O.OOO...O..O.#....#.OO.......OO..#.....O.#..#.OO#.....#.#.... +.#..##.O....##O#.O...O...#.O..#.O.O.......#..........O#.O#.O..O..O#.#O...#O.#......O.......#.####..O +....#......#...##.OOO##O.#.O##.....O.....O.........#...#.#.#.#..#.OO#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........O#O......## +..O....#.##OO.O..O##..#..OO#.....#O.#.#..#.OO......#.#..O.....O..#.O.O..O.O..........O...#.O#O...O.# +O.#.#.O.#OO...OO.......OOO..OO......#..O.OO.#............OO...#O....O.OO#.O....O........###..#...O.# +..#.O#...........O.#..O..OO.O#..#OOO.O#...OO..OO....O...#.O#.O.....#.OO.O.O...O.....#.##O.O.....#... +#......OO.O#..O.......O...#.O.O#......#.###.#.#.O.......O.#.#..O..O...O#....OO..OOO.O....##...#.#.## +.#..O...O.O..OO.....O#...#..O....O..#.....OOO...O##.........O..OOOO#........#OOO#.....O#.O.......#O# +#..OO#.O#O...O......#.....#O.#........#.....O.OO..#O#..................#OO.#..O..#...O.....O..##.#.. +.#.#O..#..OO.O.....OOO......O.O#..O...#....##...###O..OOO.....O....O.....#..#.#....OO..##.......O... +...O.OO....#.##O#..O..O.#...O.............O#...O#.##.O....OO.......OO..#OO...O#O#......O....#..OOOO. +.O..OO..#..O...#.O#.....##..#.........O.##.....O...O.....#.#.#O.....#OO......#..OO...O......#O.OO.#. +.O#OO.......O##...#............OO##....OO.O#.#O.O...#..#...#.OO.O..O.O.O#O..O...#........#.#O...O... +.#.#.O#OOO.##OO...O..O.O##.O.O#....#O....####.O.O..#..O..O.O.#....O..#....O..#......O.O.#OO..#.O.#.. +...OOO...O.....O....O......OO#...#....OO.#.O#O....O#.O.O...#.O....O.#...#.....O#..#.O#.#.O.....#OO#. +OO..O....O.O#.O...#....O.#........#.#....#....O...OOO.#.....OO..#.........O..##.........OO.........O +#...##.....OO#...#..O...#.O#.#.#O....OO.O..O#.##.O.....O.O#.#OO..#...#OOO..#....OO..#O..#O#...#.#OO. +OO.#.#....#..O.....#..OO......O......OO.OO.#..OO.#..#..#.........O#......##.##O...O#..OO.OO...#O.... +....O..#.O#.O#..##O.O...#......O.......#....#..#..##...OO.O..O#.O.....OO##.#..O.....O#.O#....O...#O. +.#.O..#.OOOO#...#O......O.#..##...#.O#...O.##OO.O.O.O...#..O#.#O...O..#O.O..OO.O.OOOO#O..O...O#..#.. +....O#..#..###..O#O....OO...#.O.O..#....#O...#O.....#OO...O...OO......##.OO.....O.O..#.....O.O.....# +...###.O....O..#..#.#OO.#.O..O.#OO.#...#....O.....#O.....#.#...OO.......O.#...O##O.......O.##.O...O. +.......#....#O#O.#...OO..#OOO.....OOO.....##....###...O...O...#OO.O.##..#OO...#..#.....O.....O.O#O.# +#O.O..O.#.O....#OO.OO....OO.....OO.OOO..##O.#.....O#OO....#O...O#..O#..#.OO.O......O...O......O#..O# +O.......#..O............#O.#O.OO.##....OO.#OO..##O...#OO....#...#..#....O#..O......O..O.#......#.O#. +O.....#O#O......#..#...OO#.....#.#.....OO#..OO#.O..#.O....#..O..#.....O...O...#......O.....OO....#.O +...#...#......O....#..O..O#O..#.##O.#O...O....O..#.O###.#.#..........O...#.....O........#..#..#...O. +.#....#.....O.#.OOO........O......#...#.O..#..O.O...O#.......O.O.#..#..O.....O......O#OOO...O#...... +.O...O#....O.....O.O...#O.#....#.##......O.O#OO#.....O..O..OOO..#...#....##.....#O.O.#.O#..........# +#....#..#..O..O#.O#O.........O..O.#.O.OO..#O....O.OO.#.OO......#.#..O...O.#.#O.#.#..O.O#..O.#...#O.# +OO...#...O...O.#O.O.#....OO##.#.#...O#....O.#..O...O...#......#.O.O...O.O.OO.#..O..O.#O..O#.#..#...# +.....O..#...O#.O.#.O.#O##O.##.OO#..O.O#O#...O#........#........OO.OOO.O.O.........#..O...........O.. +..O...O.O..O..O......O#..##.O..#.#.#......O...#...#O........###..##......O........#.#...OO.......... +.....OO#....O.#.O.O..OO#...O.....O..OO.#O..........##..##..#.O..#O.O#OO#O#.O.O#.OO....#O..O....O.... +#.O.#.#.O........#..OOOO..O.O#.#.#.....O#.O#..##.....#..O..O#O#OO...#..O#O..OO.O........#......#.#.. +.##.....O.#.......O......O##O#.........OO#..###..#............O....O.#.OO......#.....OO#..#..O...O#. +O.O..#.O.O.....O...O....O..OO....OO#...#.OO........O.O...O.....#.#....#O..#.#......#.#....#....#.O#O +..O#..#.#.#....O..#..O.O.O...#..##...O..O##.......O...O...O..O.O#O......O..O.O.OO.##OO.OO........O.. +..##.....#.O......#.O....O.O..O#..O....OO#O...O.#.O.OO#.OOO#.#.OO..#O.O#..##.O.#...#O.#.....#.O#.O.. +#O..#..O..#.O..O...O....#OOOO..O.O#.##O.O#O...#OO...O.#OOO.#.#......#...#.O#.O..##.#..#..O.#.......# +..O.#.#OO...O...O#...O...O#...O.........#...#.O..#...##..O..O.....#...OOO.##..........O..#O#O.#.O... +...#..O....#...#.O.......O...##...O..O....O.......O.....O..#..OO.....OO..#....OO#O.O#..#OO..O....#O. +.....#O.O#.#...#.O.....##..###..O......O.O#.O#.....O......#....O.O.......O#...##.O....O#O...#..##..# +....#.#..#..#..##O.##.#.O.....O..#OO..O#.O.#OO.#O#..OO..OO#.#.....O..#.OO###.##.......O...#......#.. +..O..#O.....O......#...O.#...O..O.#....#.#.O...O.#.OOO...O.O.##.....O..##....#O...##.O.O#.##O#...OO. +..#O.#...O#.#............#.O..O.#.O.#O#.#...##.O#..O##..#..#OO.O............O.#.OOOO......O.O.....## +..O...OO..#......OO.#OOOO.O.#.#..#..O..OO.O.O.....#.##O......O...O.#....O....#.OOO.O..#..#.##.O.#O.. +O.#.#.O...#..##O.OO......O.O..O.O.#O...........O...OO#O#...OO..#..O..#O...##.O......OOO.......#O..#. +......OOO....#..##O#....O.O.#.O...O#OO..#.O.......O.O..OOO.#...O.#OOO.O.OOOO#...#.....OO..O.O.OOO#.. +..OO.....#.O#......#.O..##..O..OO.O#..O#....O...O.....#..#......O.....O#.O.O#OO.OO.O.OO..#.OO.O.#O#. +.##........O.OO..#...#..#.#O.....#O..#O..O.O..#.O.OO...O.#O#...#.OO.O...#.O#....OO#...##..#O........ +O.#..O.#O.#..#..O#.......O.#.OO..OOO#..##.##.....#..#.OOO..OO#...#O.O#.O..#........##...O....O.O.OOO +.O..#..#O...OO......#...OO#.#........OO..O.#O.........O..#O.#O...##.#O..#...O...O........##..O##..O. +.O.#.....#O....O....OO....#....O..#..O......#..OOO.O.#O....OOO.#....OO.###.#....O.O..#..#..#..#..... +.#..O..#.##....#..#O.O..O.OO#..#....OO...O.O...........O#....O....O......#...O#O.....O.O.....OO.O... +##......O#...................O..O.O....#.........#....O###.#...#.OO.O..#.OO.O....OO.#.O...O...#...## +##...................O...........O.O##....##O...OOOO.O..#.O....O.#...#..OO......O.O.#O.#....#.#.O..# +...#O..O....#......#.#.#.....#.O#..###.#.#...O#OO.O..O.O...#OO#.......#.O...O.#...#...O..O..#O...#.. +O..O....#..O...#.O.O#......O.......#.OO...O...OO....O#O.OOO...O#....O...O..OO.O#.......O.O..O#...... +#...OOO.O..........#..O.#...#..O.#O.O#O.#....#.O.##....#..OO##OO.O.....OO.....OO.#.O...O.......#..O. +.O...O.O...O..O#.....##..O#.O#....OO..###O#..O#..#.#.#..O.O#..#.....##.O.#O#.O.#O.....#.O...OO...#O. +#O#.O...O#...#...O....#.O.##O#...O#.#.#O#.....O.O.O...OO#OO#...O............###....O..#OO#....O..#.O +..#..O.O#..#......#..#........O..O....#...O.O........#.#....#..#.....OOO#.#....OOOO.#O.#..##O...#..O +......O..O..O.#..#...O...#..#..O...OOO.O.OO.O...#.OOO.#...O.#...O...OO#.##..#.##.O...O.OO...OO....## +..#....O..#.#..##O.....O..O...#OOO#..O....#.......##.O..OO#.OO#O..O....O.##O..O....O##O#OO#O...#..O. +....#.#OO.#.#O...#OOO....OOOO.#..O....O...O.........#O#...###...#..OO..O.....O.O.#O..#....###O..##.. +#..O.#.O.O....OO.#..#.OOO....O.#....###O.#.##.O....#O......O..O..OOO.#..O......OOO..O.....OO.O.#.#.O +#.O.#....O..#O.##.O......OO....O.....O#O......#.O...#.##..O#..O.OO#..##..O...#.#O.O..O.O#OO.#..##O.. +....OO.O....#....O#...O..#.O..O.#.O.#.#....#.O....O#OO..O.O.O....#...#...O#O...O...O....#....O.O.O.. +.....#.OOOO.....#...#OO...O.#....###...O.O...#..#..OO..O.O#..O#OO.O.#.O#O.OO....#.#O#OO...O.OOO...#. +.O..#.#.###OOO....#..O....OO.#..O..OO..OO#O#O#..#...O...#...##O..#.......#O...##O..#...##......O.O.# +.O.###..O....O..OO#O....O#....O...O...O..#....O...#.......O.......#.O.O.#......#.OO#..O.OO..O.O.#..O +....#O...#.O.#.O.........#...#....O...#.O.#...O..#.#..O............O...O.#O..O..##.O.O...OO.#O.O...# +#.#.....OO#...O#OO.#..#..........#........O.O#.O.....O...#..#.OO#O.............O.O.##...##OO..#....# +O.OO...O#.OOO#O..O.......O##O#O###.##..#..O...#.#.....O...#..O.O..O..O#.O##.OOOO#...#.....##........ +#............#O....#....O#.....O.OO.O...#....O.#O.#...##.....O..OO#...##.O...#.O....#....O....OO#O.. +#..OO...O.....O.#..O#OO........O.......O....O#O###.#....O#O..##.###O..#O.O....O.O....O.#O..#...O##.# +..OO..#.......#...OO.#OOO#..#OO....#...OO..#O...O....O...#...O#......O.O...O##...OOO.#........O.O..O +O#.OO..O.O..#...O#O..#OO..#.#.....O.##.O.O.O.#..O.O...#O...#.......#..OOO##OO.#..O....OO....#OO.#.O. +.......#...#.#O.OOO#..#......OO.#O...##..O#.O...#O.....O..#....OO.O...OO..OO.OO..O...#.O#..OOOO#.O## +.#.#.O..O...O..#.....#..O........#.O.#..O...#.O..O..#.O.#..#..O.....O.O#...O....O....###..O.#....#.. +..O..OOOO#...#...#...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..#...#.......#.O....O.##.#O.#O..O.O.OOO..O.##.#O..#..O#.O..#O..O.#O.....#..#..O.O....... +##O#O.....O......OOO..........O#OO...OO...#..#......#.O.....O#....O..OOO......#...O..O..#O......#... +..O....O...O...##O.O#O.#.#...#.O#O...#.#......##..O#O.#.OO......##O..O#.#..O......##...#O...#..OOOO# +....#O..##.....#........O...O..###..#...O...#O.O..O.O...#..#O......O#....OO#....O.#...#..OO..#..O.O. +OOO.#O.#.#.#..O.#.#O.....#.O##............#........O..OO#O##..O...O..#..O......O....OOO..O..OO...... +..O.#......O.O..#O..O.#.O.O##...OOOO..O...#OO#.....O...OO......O.O...#.O.....OO.O.O..#.O..O.O.O...## +..OO.....#..#.....OO.#.O..#.........O..#..O.......O.##..OOO.......##.....O..#.#.O....#.O#....#..##.. +..#..OO.OO......O.O....#...O.#..#...O..O##...O.OOO....O.O#..O.#..#......#.....O.O.O#.....##.....#O.. +OO...#.##....OO.O...O..O...O..#.O.#.#.#.O.##.#...#.........O#.OO...O...#O...#....OO....#......#O.O.. +.O...#.....O.OO.O##......O...#..#..O.#.....O.#O.O.##O.O.OO.OOOO...#O.#.O....O.#..O........#..O..OOO. diff --git a/2023/day14_parabolic_reflector_dish/tests/sample_input b/2023/day14_parabolic_reflector_dish/tests/sample_input new file mode 100644 index 0000000..5a24dce --- /dev/null +++ b/2023/day14_parabolic_reflector_dish/tests/sample_input @@ -0,0 +1,10 @@ +O....#.... +O.OO#....# +.....##... +OO.#O....O +.O.....O#. +O.#..O.#.# +..O..#O..O +.......O.. +#....###.. +#OO..#....