From ad0f968b3f4de00fd26d850000425362c57240d4 Mon Sep 17 00:00:00 2001 From: Burnus Date: Mon, 16 Dec 2024 19:22:43 +0100 Subject: [PATCH] Add 2024 Day 16 --- 2024/day16_reindeer_maze/Cargo.toml | 13 ++ 2024/day16_reindeer_maze/challenge.md | 163 +++++++++++++++++ 2024/day16_reindeer_maze/src/lib.rs | 165 ++++++++++++++++++ .../day16_reindeer_maze/tests/challenge_input | 141 +++++++++++++++ 2024/day16_reindeer_maze/tests/sample_input | 15 ++ 5 files changed, 497 insertions(+) create mode 100644 2024/day16_reindeer_maze/Cargo.toml create mode 100644 2024/day16_reindeer_maze/challenge.md create mode 100644 2024/day16_reindeer_maze/src/lib.rs create mode 100644 2024/day16_reindeer_maze/tests/challenge_input create mode 100644 2024/day16_reindeer_maze/tests/sample_input diff --git a/2024/day16_reindeer_maze/Cargo.toml b/2024/day16_reindeer_maze/Cargo.toml new file mode 100644 index 0000000..fa17f51 --- /dev/null +++ b/2024/day16_reindeer_maze/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "day16_reindeer_maze" +version = "0.1.0" +edition = "2021" + +[dependencies] + +[dev-dependencies] +criterion = "0.5.1" + +[[bench]] +name = "test_benchmark" +harness = false diff --git a/2024/day16_reindeer_maze/challenge.md b/2024/day16_reindeer_maze/challenge.md new file mode 100644 index 0000000..3fa1933 --- /dev/null +++ b/2024/day16_reindeer_maze/challenge.md @@ -0,0 +1,163 @@ +It's time again for the [Reindeer Olympics](/2015/day/14)! This year, the big event is the *Reindeer Maze*, where the Reindeer compete for the *lowest score*. + +You and The Historians arrive to search for the Chief right as the event is about to start. It wouldn't hurt to watch a little, right? + +The Reindeer start on the Start Tile (marked `S`) facing *East* and need to reach the End Tile (marked `E`). They can move forward one tile at a time (increasing their score by `1` point), but never into a wall (`#`). They can also rotate clockwise or counterclockwise 90 degrees at a time (increasing their score by `1000` points). + +To figure out the best place to sit, you start by grabbing a map (your puzzle input) from a nearby kiosk. For example: + +``` +############### +#.......#....E# +#.#.###.#.###.# +#.....#.#...#.# +#.###.#####.#.# +#.#.#.......#.# +#.#.#####.###.# +#...........#.# +###.#.#####.#.# +#...#.....#.#.# +#.#.#.###.#.#.# +#.....#...#.#.# +#.###.#.#.#.#.# +#S..#.....#...# +############### + +``` + +There are many paths through this maze, but taking any of the best paths would incur a score of only `*7036*`. This can be achieved by taking a total of `36` steps forward and turning 90 degrees a total of `7` times: + +``` + +############### +#.......#....E# +#.#.###.#.###^# +#.....#.#...#^# +#.###.#####.#^# +#.#.#.......#^# +#.#.#####.###^# +#..>>>>>>>>v#^# +###^#.#####v#^# +#>>^#.....#v#^# +#^#.#.###.#v#^# +#^....#...#v#^# +#^###.#.#.#v#^# +#S..#.....#>>^# +############### + +``` + +Here's a second example: + +``` +################# +#...#...#...#..E# +#.#.#.#.#.#.#.#.# +#.#.#.#...#...#.# +#.#.#.#.###.#.#.# +#...#.#.#.....#.# +#.#.#.#.#.#####.# +#.#...#.#.#.....# +#.#.#####.#.###.# +#.#.#.......#...# +#.#.###.#####.### +#.#.#...#.....#.# +#.#.#.#####.###.# +#.#.#.........#.# +#.#.#.#########.# +#S#.............# +################# + +``` + +In this maze, the best paths cost `*11048*` points; following one such path would look like this: + +``` +################# +#...#...#...#..E# +#.#.#.#.#.#.#.#^# +#.#.#.#...#...#^# +#.#.#.#.###.#.#^# +#>>v#.#.#.....#^# +#^#v#.#.#.#####^# +#^#v..#.#.#>>>>^# +#^#v#####.#^###.# +#^#v#..>>>>^#...# +#^#v###^#####.### +#^#v#>>^#.....#.# +#^#v#^#####.###.# +#^#v#^........#.# +#^#v#^#########.# +#S#>>^..........# +################# + +``` + +Note that the path shown above includes one 90 degree turn as the very first move, rotating the Reindeer from facing East to facing North. + +Analyze your map carefully. *What is the lowest score a Reindeer could possibly get?* + +Your puzzle answer was `101492`. + +\--- Part Two --- +---------- + +Now that you know what the best paths look like, you can figure out the best spot to sit. + +Every non-wall tile (`S`, `.`, or `E`) is equipped with places to sit along the edges of the tile. While determining which of these tiles would be the best spot to sit depends on a whole bunch of factors (how comfortable the seats are, how far away the bathrooms are, whether there's a pillar blocking your view, etc.), the most important factor is *whether the tile is on one of the best paths through the maze*. If you sit somewhere else, you'd miss all the action! + +So, you'll need to determine which tiles are part of *any* best path through the maze, including the `S` and `E` tiles. + +In the first example, there are `*45*` tiles (marked `O`) that are part of at least one of the various best paths through the maze: + +``` +############### +#.......#....O# +#.#.###.#.###O# +#.....#.#...#O# +#.###.#####.#O# +#.#.#.......#O# +#.#.#####.###O# +#..OOOOOOOOO#O# +###O#O#####O#O# +#OOO#O....#O#O# +#O#O#O###.#O#O# +#OOOOO#...#O#O# +#O###.#.#.#O#O# +#O..#.....#OOO# +############### + +``` + +In the second example, there are `*64*` tiles that are part of at least one of the best paths: + +``` +################# +#...#...#...#..O# +#.#.#.#.#.#.#.#O# +#.#.#.#...#...#O# +#.#.#.#.###.#.#O# +#OOO#.#.#.....#O# +#O#O#.#.#.#####O# +#O#O..#.#.#OOOOO# +#O#O#####.#O###O# +#O#O#..OOOOO#OOO# +#O#O###O#####O### +#O#O#OOO#..OOO#.# +#O#O#O#####O###.# +#O#O#OOOOOOO..#.# +#O#O#O#########.# +#O#OOO..........# +################# + +``` + +Analyze your map further. *How many tiles are part of at least one of the best paths through the maze?* + +Your puzzle answer was `543`. + +Both parts of this puzzle are complete! They provide two gold stars: \*\* + +At this point, you should [return to your Advent calendar](/2024) and try another puzzle. + +If you still want to see it, you can [get your puzzle input](16/input). \ No newline at end of file diff --git a/2024/day16_reindeer_maze/src/lib.rs b/2024/day16_reindeer_maze/src/lib.rs new file mode 100644 index 0000000..2702bdd --- /dev/null +++ b/2024/day16_reindeer_maze/src/lib.rs @@ -0,0 +1,165 @@ +use core::fmt::Display; +use std::{cmp::Ordering, collections::{BTreeSet, HashMap, HashSet}}; + +#[derive(Debug, PartialEq, Eq)] +pub enum ParseError { + EmptyMap, + InvalidTile(char), + NoEnd, + NoStart, +} + +impl Display for ParseError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::EmptyMap => write!(f, "Map cannot be empty"), + Self::InvalidTile(e) => write!(f, "Unable to parse {e} into a map tile. Only '#', '.', 'S', and 'E' are allowed."), + Self::NoEnd => write!(f, "No end point ('E') found in input"), + Self::NoStart => write!(f, "No starting point ('E') found in input"), + } + } +} + +type Coordinates = (isize, isize); + +struct Map { + walls: HashSet, + start: Coordinates, + end: Coordinates, +} + +impl TryFrom<&str> for Map { + type Error = ParseError; + + fn try_from(value: &str) -> Result { + let mut walls = HashSet::new(); + let mut start = None; + let mut end = None; + + for (y, line) in value.lines().enumerate() { + for (x, c) in line.chars().enumerate() { + match c { + '#' => _ = walls.insert((x as isize, y as isize)), + 'S' => start = Some((x as isize, y as isize)), + 'E' => end = Some((x as isize, y as isize)), + '.' => (), + e => return Err(Self::Error::InvalidTile(e)), + } + } + } + if let Some(start) = start { + if let Some(end) = end { + Ok(Self { walls, start, end, }) + } else { + Err(Self::Error::NoEnd) + } + } else { + Err(Self::Error::NoStart) + } + } +} + +#[derive(PartialEq, Eq, PartialOrd, Ord)] +struct SearchState { + costs: usize, + pos: Coordinates, + facing: Coordinates, +} + +impl Map { + fn solve(&self) -> (usize, Vec) { + let start = SearchState { + costs: 0, + pos: self.start, + facing: (1, 0), + }; + let mut open_set = BTreeSet::from([start]); + let mut visited = HashSet::new(); + let mut came_from: HashMap<(Coordinates, Coordinates), (Vec, usize)> = HashMap::new(); + let mut best_costs = usize::MAX; + while let Some(curr) = open_set.pop_first() { + if curr.costs > best_costs { + break; + } + if curr.pos == self.end { + best_costs = curr.costs + } + if visited.contains(&(curr.pos, curr.facing)) { + continue; + } + visited.insert((curr.pos, curr.facing)); + neighbours(curr.pos, curr.facing) + .iter() + .filter(|(pos, _facing, _costs)| !self.walls.contains(pos)) + .for_each(|&(pos, facing, addidtional_costs)| { + let costs = curr.costs + addidtional_costs; + open_set.insert(SearchState { pos, facing, costs, }); + came_from.entry((pos, facing)) + .and_modify(|(was_facing, best_costs)| { + match costs.cmp(best_costs) { + Ordering::Less => *was_facing = Vec::from([curr.facing]), + Ordering::Equal => was_facing.push(curr.facing), + Ordering::Greater => (), + } + }).or_insert((Vec::from([curr.facing]), costs)); + }); + } + let mut path = Vec::from([self.end]); + let mut open = came_from.keys().filter(|(pos, _facing)| *pos == self.end).copied().collect::>(); + while let Some(this) = open.pop() { + came_from.get(&this) + .unwrap() + .0 + .iter() + .for_each(|prev_facing| { + let prev_pos = (this.0.0 - prev_facing.0, this.0.1 - prev_facing.1); + if !path.contains(&prev_pos) && this.0 != self.start { + path.push(prev_pos); + open.push((prev_pos, *prev_facing)); + } + }); + } + + + (best_costs, path) + } +} + +fn neighbours(pos: Coordinates, facing: Coordinates) -> [(Coordinates, Coordinates, usize); 4] { + [ + ((pos.0+facing.0, pos.1+facing.1), facing, 1), // go ahead + (pos, (facing.1, facing.0), 1000), // turn one way + (pos, (-facing.1, -facing.0), 1000), // turn other way + (pos, (-facing.0, -facing.1), 2000), // turn around + ] +} + +pub fn run(input: &str) -> Result<(usize, usize), ParseError> { + let map = Map::try_from(input)?; + let path = map.solve(); + let first = path.0; + let second = path.1.len(); + 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((7036, 45))); + } + + #[test] + fn test_challenge() { + let challenge_input = read_file("tests/challenge_input"); + assert_eq!(run(&challenge_input), Ok((101492, 543))); + } +} diff --git a/2024/day16_reindeer_maze/tests/challenge_input b/2024/day16_reindeer_maze/tests/challenge_input new file mode 100644 index 0000000..d68d447 --- /dev/null +++ b/2024/day16_reindeer_maze/tests/challenge_input @@ -0,0 +1,141 @@ +############################################################################################################################################# +#.......#...#.#.........#...#.........#.......#.................#...........#...............#.............#.......#.......#.#.............#E# +###.#.#.#.#.#.#.###.###.#.###.#.#######.#.###.#.#.###.#########.#.#####.#.#.#.###.#.###.#.#.#####.###.###.#####.#.###.###.#.#.#.#.#.#####.#.# +#.....#...#.#.....#.......................#.#.#.....#.#.....#.#.#.#.....#.#.#.#.#.#...#.#.#.................#...#...#.#.....#...#.#...#.....# +#.#.#.#####.#.#####.#.#.#####.#########.#.#.#.#.#.#.###.###.#.#.#.#.#####.#.#.#.#.###.#.#.#####.###.#.#.###.#.#####.#.#########.#.###.####### +#.#.....#...#.#.....#.#.....#.#...#.......#...#...#.......#.#...#.#.....#...#.#...#...#...#...#.#.....#...#...#...#.#.........#.#...#.......# +#.#.#.###.###.#.#####.#####.#.#.#.#.###.###.###.#.#########.#####.#####.#.###.#.###.#######.#.#.#.#######.#####.###.#######.#.#.#.#.#######.# +#.#...........................#.#...#.....#.#...#.#.......#...........#.#.....#.#...#.......#...#.#.......#...#.............#.#.#.#.......#.# +#.#.#.#####.#.#.#########.#.###.#####.#.#.#.#.#.#.#.#####.#############.#######.#.###############.#.#######.#.#.###.###########.#.#####.###.# +#.......#...#...#.......#.....#...#.#...#...#.#...#...#.....#.........#.#...#...#.#...............#.#...#...#.#.#...#...........#.#.....#...# +#.#.###.#.###.#.#.#####.#####.###.#.###.#######.#.###.#####.#.#######.#.###.#.###.#.###############.#.#.#.#.#.#.#.#.#.#####.###.#.#.#####.#.# +#.#...................#.....#.#...#...#.#.....#.....#...#...#.....#...#...#.#.#.................#...#.#.#...............#.....#...#...#...#.# +#.#.#####.#.#.###.#.#######.#.#.#####.#.#.###.#########.#.#######.#.#####.#.#.#.#.###########.#.#.###.###.###.#.###.###.#.#.#.#.#.###.#.###.# +#.#...#.#.#.......#.....#.#.#.#.#...#.....#.....#.......#.........#.......#.....#.....#.........#.#.#.....#.........#...#.#.#.#.#.#...#.#...# +#.#.#.#.#.###.#####.#.#.#.#.#.#.#.#.#.#########.#.#####.###################.#.#########.#######.#.#.#.#####.#.#.###.#.#####.#.#.#.#.###.#.### +#...#.#.#...#.....#...#...#.#...#.#.#...#...#.#.#...#...#.........#.......#.#...........#.....#.#.#...#.....#.....#.#.#.....#.#...#...#.#...# +#####.#.###.#####.###.#####.#####.#.#####.#.#.#.###.#.###.#######.#.#####.#.#.###.#.#####.###.###.#.#######.#.#.###.#.###.###.###.###.#.##### +#.....#.....#.#...#...#.....#.....#.......#.#.#.#...#...#.#.....#...#.#...#.#.#.#.......#.........#.........#.#.#...#...#...........#.#.....# +#.#####.#####.#.###.###.#.###.#########.###.#.#.#.#####.#.#####.#####.#.#####.#.#########.#######.###########.###.#.###.#.#######.#.#.#####.# +#.....#.#...#.......#...#.#...#...........#.#.....#.....#.....#.......#...#...............#.....#.#.....#...#...#...#.#.#...#.#...#.#...#...# +#####.#.###.#.#######.###.#.#######.#.#####.#.###############.#.#########.#.#####.#####.#.#.###.###.###.#.#.###.###.#.#.###.#.#.#.#.###.#.#.# +#.....#...#.....#.....#...#...#...#.#.......#.#.......#.....#...#.............#...#.......#.#.#.#...#.#...#...#...#...#.....#.#.#.......#.#.# +#.#######.#.#####.###.#######.#.#.#.###.#.###.#.#####.#.###.###.#.#####.#####.#.###.#######.#.#.#.###.#####.#.#.#.#.#########.#.#.#######.### +#.#.....#.#.#...#.#...#.....#.#.#.#...#.....#.#...#.#...#.#.#...#...#.....#...#...#.#.#.....#.#.#.#.........#.#.#...#.........#.#.......#...# +#.#.###.#.###.#.#.###.#.###.#.#.#.#####.###.#####.#.#####.#.#.#####.#####.#####.#.#.#.#.#####.#.#.#.#####.#.#.#.###.#.#####.###.#.#####.###.# +#.#...#.#...#.#.#...#.#.#...#...#.#.......#.....#.#.......#...#...#...#.#.....#.#.#.#.#.#.....#...#...#...#.#.#...#.#.....#.....#.#.....#...# +#.#.###.###.#.#.###.###.#.#######.#.#########.###.#.#####.#####.#####.#.#####.###.#.#.#.#.#.###########.###.#.#.#.#######.#######.#.#####.#.# +#...#...#.....#.....#...#.....#...#.........#.#...#.....#.#...#.....#.#.......#...#.#.#.#.#.............#...#...#.........#.....#.#.#.....#.# +#.###.#############.#.#######.#.#####.###.#.#.#.###.###.#.#.###.#.###.###.#####.###.#.#.#.###.###########.#####################.#.#.#####.#.# +#.#...#.....#...#...#.....#...#.....#...#.#.#.#.#...#...#.#.....#...#...#.......#.#...#.#...#...#.....#...#...........#.........#.#.....#.#.# +#.#.###.###.#.###.#####.###.#.#####.#.###.#.#.#.###.#.###.#.#######.###.#########.###.#.###.###.#.###.#.###.#.#######.###.#.#####.#####.#.#.# +#...........#.......#...#...#...#.#.#.#...#.#.....#.#.#.#.#.#.....#...#...#...........#...#.#...#.#.#...#.#.#...#.........#.......#.#...#.#.# +#.#.#.###.#.#######.#.###.#####.#.#.###.#####.###.#.#.#.#.###.###.#.#####.#######.#######.###.###.#.#####.#.###.#.###########.#####.#.###.#.# +#.#.......#.....#.....#.#.....#...#...#...#...#...#.#.#...#...#...#.....#...#...#.#.......#...#.........#.......#.#.........#...#.....#...#.# +#.###########.#.#####.#.#####.#######.###.#.###.#####.#.###.###.#####.#.###.#.#.###.#######.###########.#####.#####.#######.#.#.#.#.###.###.# +#.#.#.......#...#.....#.....#...#.....#...#.....#.....#.....#.#.......#.#.#...#...#.#.......#.....#...#.....#.#.....#.....#.#.#.#.......#...# +#.#.#.#####.#.#.#.#####.###.###.#.#.###.#.#########.#.#.#.#.#.#####.###.#.#######.#.#.###.###.###.#.#.#####.#.#.#####.###.#.###.###.#####.### +#.#.#...#.......#.#...#.#.....#...#.......#.........#.#...#.#.........#...#.....#...#...#...#...#...#.#...#.#.#.......#...#...#.#.....#.....# +#.#.###.#####.#.#.#.#.#.#.###.#######.#####.#####.###.#.###.#####.###.###.#####.###########.#.#.#####.###.#.#.#########.#####.#.#.#.#.#####.# +#.#...#.......#.#...#.#.#.#.#.#.....#.......#...#.#...#.....#...#.......#.....#...........#...#.....#...#.#.....#.......#...#.#.#.#.#.#...#.# +#.###.#######.#####.#.#.#.#.#.#.###.#.#########.#.#.#####.###.#.#######.#####.#####.#####.#.#.#####.###.#.###.###.#####.#.#.#.#.#.#.#.#.#.### +#.......#...#.........#.#.#.#...#...#...........#.#...........#...#.....#...#.....#...#.#.#.#.....#.#.#.#...#.#...#.......#...#.....#...#...# +#######.###.#.#######.#.#.#.#####.#####.#####.#.#.#####.#.#######.#.#.#.#.#.#####.###.#.#.#.#.#####.#.#.###.#.#.#####.#############.###.###.# +#.....#.#.....#...#.#...#.#...#...#.....#...#...#...#...#.#.....#.#.#...#.#.#...#.#...#.#...#.........#...#...#.....#.#...#...........#.#...# +#.#.#.#.#.###.#.#.#.#.###.#.###.###.#####.#.#.#####.#.#.###.###.#.#.###.#.#.###.#.#.###.#.#######.###.###.#.#######.#.#.#.#.#######.#.###.### +#.#.#.#.#.#.....#.......#.#.....#...#.....#...#.....#.#.#...#...#.#...#.#.#.....#.#...#.............#...#.#.#.#.....#...#.#.#.......#...#...# +###.#.#.#.###.###.#######.#.#####.#.#.#########.#####.#.#.###.###.###.#.#.#####.#.###.#########.#.#.###.#.#.#.#.#####.###.#.###.###.###.###.# +#.............#.....#.....#...#.#.....#.......#.#.#...#.#.#.......#...#...#.....#...#...#...#...#.......#.#...#...#.....#.#...#...#...#.#...# +#.#####.#.###.#####.#.#######.#.#.#####.#####.#.#.#.#.#.#.#.###.###.#######.###.###.###.###.#.###.#######.###.###.###.#.#.#.#.#.#.#.###.#.#.# +#.......#...#.....#.#.#...#...#.#.......#...#...#.....#.#.#...#.#...#.....#.....#...#...#...#...#.#.........#...#...#.#...#.#.#.#.......#.#.# +#.#########.#.###.#.#.#.###.###.#.###.#.###.#####.###.###.###.#.###.#.#.###.#####.#.#.###.#.###.###.###.###.#.#####.#.#####.#.#.###.#####.#.# +#.#.....#...#...#.#...#.#...#.....#.....#...#.......#.....#.#.#.....#.#.....#...#.....#...#...#...#.#.#.....#.#.....#...#...#.#.#.........#.# +#.###.#.#.###.###.#####.#.###.#####.#####.#.#.#########.###.#.###.#####.#####.###.#####.#####.###.#.#.#######.#.#######.#####.#.#####.###.### +#.#...#.#.....#...#.#...#...#.#.....#.....#.#...#.....#.....#.#...#...#.#...#.......#...#.#...#.#...#...#.....#...............#.....#...#...# +#.#.###.#####.#.#.#.#.#.###.#.#.#####.#########.#.###.#####.#.#.###.#.#.#.#.###.###.###.#.#.###.#####.#.#.#####.#.###.#####.#######.###.#.#.# +#...#.#.........#...#.#.....#.#.#.#.............#...#.#.....#.#.#.#.#.#...#.....#.#.....#.#.#...#...#.#...#.#...#...#...#.........#...#...#.# +#####.###########.#.#.#########.#.#.#############.###.#.#####.#.#.#.#.###########.#######.#.###.#.#.#.#####.#.#####.###.#.#######.###.###.#.# +#.....#...............#...#.....#.........#...#...#...#.#.....#.#.#...........#...#.......#...#.#...#.......#.......#...#...#.#.....#.....#.# +###.###.###############.#.#.#####.#######.###.#.###.###.#.#####.#.#.#########.#.#.#.#.#.#####.#.#.#.#######.#########.#####.#.#.#.#.#####.#.# +#...#...#.........#...#.#...#...#.....#.......#...#.#.#.#.#.......#.#.....#...#.#.#.#.#.#.....#...#.......#.....#...#.....#...#.#.......#...# +#.#.#.#########.#.#.#.#.#####.#.#.###.###########.#.#.#.#.#########.###.#.#.###.#.#.#.###.###########.#.#######.#.#.#####.###.#.#.#######.#.# +#.#.#.....#.....#...#.#...#...#.....#...#.......#.#.#...#.........#.....#.#.#...#.#.#.............#...#.#.......#.#.......#.#.#.#.#.......#.# +#.#######.#.#####.###.#.#.#.###########.#.###.###.#.#####.#######.#######.#.#####.#.###########.#.#.###.#.#######.#.#######.#.#.#.#.#####.#.# +#.....................#.#.#.#.#.......#.#...#.....#.#...#.#.....#.........#.....#.....#.......#.....#...#.....#...#.#.....#...#.....#...#...# +###.#######.#########.###.#.#.#.#####.#.###.#######.#.#.#.###.#.#######.#.#####.#.#####.#####.#######.#######.#.#####.###.#.#####.#####.#.### +#...#.......#.......#.....#...#...#.....#...#.....#...#.#...#.#.....#...#...#.#.........#.....#.....#.#.#...#.#.........#.#.............#...# +#.###.#######.#####.#######.#.###.#####.#.###.###.#####.###.#####.#.#.#####.#.###########.###.#.###.#.#.#.#.#.###########.#############.#.#.# +#.#...#.....#.#...#.....#.....#.#.#...#.#.....#...#...#.#.#.....#.#.#.........#...#.....#...#.#.#.#.#...#.#...#.........#.#...........#...#.# +#.#.###.#.###.#.#######.#.#####.#.#.#.#.#.#.###.###.#.#.#.#####.###.#########.#.#.#.###.###.###.#.#.#####.#.###.###.#.#.#.#####.#.#######.#.# +#.#.#...#...#.#.#.....#.#.#.....#...#.#.#.#.#.#.#.#.#...#.....#.....#.#...#.......#.........#...#.#...#.........#...#.#.#.......#.......#.#.# +#.#.#.#####.#.#.#.#.###.#.#####.#####.###.#.#.#.#.#.#####.###.#####.#.#.#.###########.#######.###.###.#.#########.###.#.###.###.#####.#.#.#.# +#...#...#...#.#.#.#.#...#.#...#...#...#...#.#...#.#...#.....#.....#.#.#.#.#.........#.......#.#.....#...#.....#.....#.#...#...#.#...#.#.#...# +#.###.#.#.###.#.#.#.#.#.#.#.#.#.#.#.###.###.#.###.###.#####.#####.#.#.###.#.#######.#.#####.#.#.###.#####.###.###.###.###.#####.#.#.#.#.###.# +#.....#...#...#...#.#.#.#.#.#...#.#...#...#.#...#...#.....#...#.....#...#...#.......#.....#.#.#.#...#...#.#.#.........#.......#...#.#.#...#.# +#.###.#####.###.###.#.#.#.#.#####.###.###.#.###.#.#######.###.#.###.#.#####.###.#.#.#####.#.#.#.###.###.#.#.###########.###.#.#.###.###.###.# +#.#.........#.#.#.#.#.#.#...#...#.#.#.#...#...#.#.......#...#.#...#.#.#.....#...#...#.....#.#.#...#.....#.#...........#...#.#.#...#...#.#...# +#.#.#.#######.#.#.#.#.#######.#.#.#.#.#.###.#.#.#.###.#####.#.#####.#.#.#.#.#.#####.#.###.#.#.#.#.###.###.#.#.###.#.#####.#.#.#######.#.#.### +#.................#.#...#.....#.#...#...#.....#.#.........#.#.......#...#.#...#.....#.#...#...#.#...#.#...#.#.....#.....#...#.........#.#.#.# +#.###.#.###.#####.#.###.#.#####.###.#####.#####.###.###.###.#.#######.###.###.#.#####.#.###.###.###.#.#.###.#########.#################.#.#.# +#.#.#...#.#.....#.#...#...#...#...#.....#.....#.#.....#.#.........#...#.#.#.......#...#.#...#...#...#.#.#.#.#.....#...#...........#.....#...# +#.#.#.###.#####.#.###.#######.#.#.#.###.#####.#.#######.#.#######.###.#.#.#.#####.###.#.#.#######.###.#.#.#.###.###.#.#.#####.###.#.###.###.# +#.#...#...#...#.#.#.....#.....#.#.............#.....#...#.#.....#.....#.#.#.#...#.....#.#.........#...#.#.#...#...#.....#...#...#.#.#.....#.# +#.#.#.#.#.#.#.#.#.#.#####.#.###.#####.#############.#.###.#.#.#.###.#.#.#.#.#.#.#######.#.#########.###.#.###.#.#.#########.###.#.###.#####.# +#...#.#.#...#...#.#.......#...#.#...#.............#...#...#.#...#...#...#.#.#.#...#.....#.#.....#.....#.#.....#.#...........#...#...#.#...#.# +#####.#.#.###.###.###########.#.#.#.#############.###.#.###.#.###.###.###.#.#####.#.#######.###.#####.#.#.#.#####.#.#########.#####.#.#.#.#.# +#.#...#.......#.#.#.......#...#.#.#...#.........#.#.#.#.#...#.......#.#...........#.#.......#.#...#...#.#...........#.........#...#...#.#...# +#.#.#.###.###.#.#.###.###.#.###.###.###.#.#.#####.#.#.#.#.#########.###.###.#######.#.#.#####.###.#####.###########.#.#.#.#####.#.###.#.##### +#.#.............#...#.#...#...#...#.....#.......#...#.#.#.#.......#.....#...#.......#.#.#.....#.#.....#.......#...#...#...#.....#.#.#.#.....# +#.#.#####.#.#.#.###.###.#.###.###.#.#######.###.###.#.#.###.#####.###########.#########.#.#.#.#.#####.#####.#.#.#.#.#.#####.#####.#.#.#####.# +#.#.........#.#.........#...#.#...#...#...#...#.....#.#.......#...#...........#.........#.#.#.......#.....#.#.#.#...#...#...#.#...#.#...#...# +#.#####.#.###.###########.###.#.###.#.#.#.###########.#########.###.###########.###.#####.#.#.###########.#.#.#######.#.#.###.#.###.###.#.### +#.......#.....#.......#...#...#.....#.#.#.......#.........#...#.#...#.............#.#...#.#.#...#.....#...#.........#.#.#.....#.#.......#...# +#.#######.#####.#####.#.###.#.#####.###.#######.#.#####.###.#.#.#.#######.#######.#.#.###.#.#.#.#.###.#.###.#######.###.###.#.#.#.#########.# +#.#.....#.....#.#.....#.#...#.#...#.....#.....#...#.......#.#...#.........#.......#.#.....#...#.#...#.#...#...#...#...#.....#.#.#.#.......#.# +#.#.###.#.###.#.#.#####.#.###.#.#########.###.###########.#.#######.#.#####.#######.###.#######.#.#.#.###.###.#.#.#.#.###.###.#.#.###.###.#.# +#.#...#...#...#.#.#.....#.#...#...#.....#...#.............#.#.....#...#...#.....#.....#.......#.#...#...#.#.....#...#...#.....#.#...#.#...#.# +#.#.#####.#.###.#.#####.#.###.###.#.#.#.#########.#######.#.#.#.#######.#######.#.###.#######.#.#.#####.#.#########.###.#.#####.###.###.#.#.# +#.#.#...#.#.....#.....#.#...#.....#.#.#...........#.......#.#.#.......#.......#.#.............#.......#...#.....#.......#.....#.#.......#.#.# +#.###.#.#.#########.#.#.###.#####.#.#.#############.#######.#.#####.###.###.###.#.#####.#.#.#.#######.#.###.###.#######.#####.#.#.#########.# +#.....#...#.........#.#.#...#...#.#.#...#...#.......#...#...#.#...#.......#.#...#.#...#...#.#...#...#.#.....#.#.....#...#.#...#.#...#...#...# +#####.###.#.#.#####.#.#.#.###.#.#.#.###.#.#.#######.#.#.#.#.#.###.#####.###.#.#####.#.#####.#####.#.#.###.###.#####.#.###.#.###.#.###.#.#.### +#...#.#.....#...#...#.#...#...#...#...#.#...#.....#.#.#.#.#.#.......#.......#...#...#.......#.....#.#...#.#.......#...#.#...#...#.#...#...#.# +#.###.#.#.#####.###.#.#.#.#.#####.###.#.#.#.#.###.#.#.#.#.#.###.#####.#########.#.###########.#####.###.#.#.#.#########.#.###.###.#.#######.# +#.....#.......#.....#.#...#.#.......#.#...#.....#.#.#.#...#.#...#.....#.....#...#.......#...#.....#.#.....#.#.#...........#.#...#.#.#.......# +#.#######.###.#####.#.#.#.###.#####.#.#####.#####.#.#.###.#.#.###.###.#.###.#.###.#####.#.#.#####.#.###.#####.#.#.#######.#.###.###.#.#.##### +#.......#.....#.#...#.#.#.........#...#...#...#...#...#...#.#.#...#...#.#.#...#.......#...#.......#...#.#...#...#.....#...#...#.....#.#.....# +#####.###.#####.#.###.#########.#######.#.###.#.#####.#.###.#.#.#####.#.#.#####.#######.#############.###.#.#########.#.#####.#############.# +#.....#...#.....#.....#.......#.#...#...#...#.#.#.....#.#...#.#.#...#...........#.....#...........#.#.....#...........#.#...#...............# +###.###.#.#####.#######.#####.###.#.#.#####.###.#.#####.#####.#.#.#.#######.#####.###.###########.#.#########.#.#####.#.#.#.###.#####.#####.# +#...#...#.......#.....#.....#.....#.#...#.#...#.#.#...#.......#.#.#.......#.....#.#...#.............#.....#...#.#.....#...#...#.....#...#...# +#.#.#.#.#.#.###.#.#####.###.#.#####.###.#.###.#.#.#.###########.#.#######.#####.#.#.###############.#.###.#.###.#############.#########.#.### +#.#...#.....#.#.#.....#...#.#.#...#...#.#.#...#.#.#...........#...#.....#.....#.#.#.....#.........#.#.#...#.#...#.....#.....#...........#.#.# +#.#####.#.###.#.#.###.###.#.###.#.###.#.#.#.###.#.###.###.#.#######.###.#####.#.#.#####.#.#######.#.###.#.#.###.#.###.#.###.#############.#.# +#.....#.#.......#.....#.......#.#...#...#.#.#...#...#.#...#.#.....#...#.....#...#...#...#.#.......#.#...#.#...#.....#...#...#...#.......#.#.# +#####.#.###.#########.#.#####.#.###.#####.#.#.#####.#.#.###.#.#.#.###.#####.#######.#.###.#.#######.#.#.#.###.###########.#.###.#.###.###.#.# +#.....#...#.#.....#...#.#.....#.#.#.....#.....#...#...#...#...#.#...#...#...#.......#.#...#.#.....#...#.#.....#...........#.....#.#...#...#.# +#.#####.#.#.###.#.#.###.#.#.#.#.#.#####.#.###.###.###.###.#.###.###.###.#.###.#####.#.###.#.###.###.#####.#####.#######.#######.#.#.###.###.# +#...#.#...........#.......#.#.#.....#...#.#...#...#...#.#.#...#.#.#.....#.....#...#...#...#...#.#...#.....#.....#.......#.....#.#.#...#...#.# +###.#.#.#.#.#.###.###########.#####.#.###.#.#.#.#.#.###.#.#.#.#.#.#.###########.#.#.###.#####.#.#.###.#####.###.#.#####.###.#.#.#.###.###.#.# +#.#.#...#.#.#.#...#.........#.#.....#...#.#.#.#.#...#...#...#.#.#.............#.#.#.#...#.#...#.#.#.#.#.#...#.#...#...#...#.#...#...#.....#.# +#.#.###.#.#.#.#.###.#####.#.#.#.#######.###.#.#.###.#.###.#.###.#.###.###.###.###.#.###.#.#.###.#.#.#.#.#.#.#.#######.###.#########.#######.# +#.#.......#...#.#.....#.......#.....#.#.....#.#.......#...#...#.#.......#.#.#.....#.....#...#.#.....#.#...............#.#.#.........#.......# +#.#.###.#####.#.#####.#.###########.#.#####.#.#########.###.#.#.#####.#.#.#.#####.#######.###.#.#####.#.#############.#.#.#.#########.#.###.# +#.......#.....#...#...#.#.....#.......#...#.#...#.....#.#...#...#...#.#.#.#.....#.#...#...#...#.#.....#.#...#...#.....#.#.#.#.....#.#.#.#.#.# +#.#.#.#.#.###.###.#.###.#.###.#.#######.#.#####.#.###.#.#.#######.###.#.#.#####.#.###.#.#####.#.#.#######.#.#.###.#####.#.#.###.#.#.#.#.#.#.# +#.#...#...#...#.#.#...#.#.#...#.#...#...#.......#.#.#...#.#...#.....#.#.#.#...#.........#...#...#.........#.#.#.........#.#.....#.#...#.#...# +#.#.###.#####.#.#.#.#.###.#.###.#.#.#.#.#.#######.#.#####.#.#.#####.#.#.#.#.#.#######.#.#.#.#.#####.#######.#.#.#########.#######.#.###.#.### +#.#.....#...#...#.#.#...#.#.....#.#.#.....#.............#...............#.#.#...#.....#.#.#.#.#...#.#...#...#.....#.....#.....#...#.#.#.#...# +###.###.#.#.#.###.#.###.#.#######.#####.#.#.#######.#####.#.#.###.###.###.#.###.###.###.#.#.###.#.#.###.#.#####.###.###.#.#####.###.#.#.##### +#.....#.#.#.#...#.#...#.......#.....#...#.....#...#.#...#.#.....#.....#...#...#...#...#...#...#.#.#.......#...#.#...#.....#...#.#.....#.....# +#.#.#.#.#.#.#.#.#.###.###.###.#.###.#.#.#######.#.###.#.#.#.#.#.#####.#.#.###.###.#.#########.#.#.#######.#.#.###.###.#.#.#.#.#.#####.#####.# +#.#.#.#.#.#...#.#.#.#.#.....#.#...#...#.#.......#.#...#...................................#.#...#.......#...#...#.......#.#.#.#.....#...#...# +#.#.#.#.#.#.#.#.#.#.#.#.###.#.#########.#.#######.#.#.#######.###.#######.#.###.###.###.#.#.###########.#.#####.#.###.#.###.#.#####.#####.### +#.#.....#.#...#.#.#...#.#.#.#...#...#...#...#.#...#.#.....#...#.......................#.#.......#.......#.#...#.#.#.....#...#.....#.....#...# +#.#.#####.#.#.#.#.#.###.#.#.###.#.#.#.#####.#.#.###.#.#.#.#.#.#####.#.#####.#.###.#.#.#.###.#####.#######.#.#.#.#.#.#.#.#.#####.#######.###.# +#.......#.#...#.#.#...#.#.........#...#...#.#...#...#.#.....................#.#...#...#...#.#.....#.....#...#.#.#.#...#.#.....#...#...#.#...# +#.#.###.#.#.#.#.#.#####.#.#########.###.#.#.#.#####.###.###.#.###.#.###########.###.#####.#.#.#######.#.#######.###.#.#######.###.#.#.#.#.#.# +#.....#...#...#...#...#.#.........#.....#...#.....#...#.#.......................#.#.....#...#.#.......#...#...#...#.#...#...#.#.#.#.#...#.#.# +#####.#####.#.#####.#.#.#########.###.###########.###.#.#####.#.#####.#.###.#.#.#.#####.#.###.#.#########.#.#.###.#.#.#.#.#.#.#.#.#.#####.#.# +#S....................................#...............#...............#.........................#...........#.....#...#...#.....#.........#.# +############################################################################################################################################# diff --git a/2024/day16_reindeer_maze/tests/sample_input b/2024/day16_reindeer_maze/tests/sample_input new file mode 100644 index 0000000..2c21676 --- /dev/null +++ b/2024/day16_reindeer_maze/tests/sample_input @@ -0,0 +1,15 @@ +############### +#.......#....E# +#.#.###.#.###.# +#.....#.#...#.# +#.###.#####.#.# +#.#.#.......#.# +#.#.#####.###.# +#...........#.# +###.#.#####.#.# +#...#.....#.#.# +#.#.#.###.#.#.# +#.....#...#.#.# +#.###.#.#.#.#.# +#S..#.....#...# +###############