Added Solution for 2023 day 21
Added Solution for 2023 day 21
This commit is contained in:
parent
e341db7a22
commit
b992be36c8
5 changed files with 499 additions and 0 deletions
15
2023/day21_step_counter/Cargo.toml
Normal file
15
2023/day21_step_counter/Cargo.toml
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
[package]
|
||||||
|
name = "day21_step_counter"
|
||||||
|
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
|
170
2023/day21_step_counter/challenge.txt
Normal file
170
2023/day21_step_counter/challenge.txt
Normal file
|
@ -0,0 +1,170 @@
|
||||||
|
You manage to catch the [airship](7) right as it's dropping someone else off on their all-expenses-paid trip to Desert Island! It even helpfully drops you off near the [gardener](5) and his massive farm.
|
||||||
|
|
||||||
|
"You got the sand flowing again! Great work! Now we just need to wait until we have enough sand to filter the water for Snow Island and we'll have snow again in no time."
|
||||||
|
|
||||||
|
While you wait, one of the Elves that works with the gardener heard how good you are at solving problems and would like your help. He needs to get his [steps](https://en.wikipedia.org/wiki/Pedometer) in for the day, and so he'd like to know *which garden plots he can reach with exactly his remaining `64` steps*.
|
||||||
|
|
||||||
|
He gives you an up-to-date map (your puzzle input) of his starting position (`S`), garden plots (`.`), and rocks (`#`). For example:
|
||||||
|
|
||||||
|
```
|
||||||
|
...........
|
||||||
|
.....###.#.
|
||||||
|
.###.##..#.
|
||||||
|
..#.#...#..
|
||||||
|
....#.#....
|
||||||
|
.##..S####.
|
||||||
|
.##..#...#.
|
||||||
|
.......##..
|
||||||
|
.##.#.####.
|
||||||
|
.##..##.##.
|
||||||
|
...........
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
The Elf starts at the starting position (`S`) which also counts as a garden plot. Then, he can take one step north, south, east, or west, but only onto tiles that are garden plots. This would allow him to reach any of the tiles marked `O`:
|
||||||
|
|
||||||
|
```
|
||||||
|
...........
|
||||||
|
.....###.#.
|
||||||
|
.###.##..#.
|
||||||
|
..#.#...#..
|
||||||
|
....#O#....
|
||||||
|
.##.OS####.
|
||||||
|
.##..#...#.
|
||||||
|
.......##..
|
||||||
|
.##.#.####.
|
||||||
|
.##..##.##.
|
||||||
|
...........
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, he takes a second step. Since at this point he could be at *either* tile marked `O`, his second step would allow him to reach any garden plot that is one step north, south, east, or west of *any* tile that he could have reached after the first step:
|
||||||
|
|
||||||
|
```
|
||||||
|
...........
|
||||||
|
.....###.#.
|
||||||
|
.###.##..#.
|
||||||
|
..#.#O..#..
|
||||||
|
....#.#....
|
||||||
|
.##O.O####.
|
||||||
|
.##.O#...#.
|
||||||
|
.......##..
|
||||||
|
.##.#.####.
|
||||||
|
.##..##.##.
|
||||||
|
...........
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
After two steps, he could be at any of the tiles marked `O` above, including the starting position (either by going north-then-south or by going west-then-east).
|
||||||
|
|
||||||
|
A single third step leads to even more possibilities:
|
||||||
|
|
||||||
|
```
|
||||||
|
...........
|
||||||
|
.....###.#.
|
||||||
|
.###.##..#.
|
||||||
|
..#.#.O.#..
|
||||||
|
...O#O#....
|
||||||
|
.##.OS####.
|
||||||
|
.##O.#...#.
|
||||||
|
....O..##..
|
||||||
|
.##.#.####.
|
||||||
|
.##..##.##.
|
||||||
|
...........
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
He will continue like this until his steps for the day have been exhausted. After a total of `6` steps, he could reach any of the garden plots marked `O`:
|
||||||
|
|
||||||
|
```
|
||||||
|
...........
|
||||||
|
.....###.#.
|
||||||
|
.###.##.O#.
|
||||||
|
.O#O#O.O#..
|
||||||
|
O.O.#.#.O..
|
||||||
|
.##O.O####.
|
||||||
|
.##.O#O..#.
|
||||||
|
.O.O.O.##..
|
||||||
|
.##.#.####.
|
||||||
|
.##O.##.##.
|
||||||
|
...........
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
In this example, if the Elf's goal was to get exactly `6` more steps today, he could use them to reach any of `*16*` garden plots.
|
||||||
|
|
||||||
|
However, the Elf *actually needs to get `64` steps today*, and the map he's handed you is much larger than the example map.
|
||||||
|
|
||||||
|
Starting from the garden plot marked `S` on your map, *how many garden plots could the Elf reach in exactly `64` steps?*
|
||||||
|
|
||||||
|
Your puzzle answer was `3617`.
|
||||||
|
|
||||||
|
\--- Part Two ---
|
||||||
|
----------
|
||||||
|
|
||||||
|
The Elf seems confused by your answer until he realizes his mistake: he was reading from a list of his favorite numbers that are both perfect squares and perfect cubes, not his step counter.
|
||||||
|
|
||||||
|
The *actual* number of steps he needs to get today is exactly `*26501365*`.
|
||||||
|
|
||||||
|
He also points out that the garden plots and rocks are set up so that the map *repeats infinitely* in every direction.
|
||||||
|
|
||||||
|
So, if you were to look one additional map-width or map-height out from the edge of the example map above, you would find that it keeps repeating:
|
||||||
|
|
||||||
|
```
|
||||||
|
.................................
|
||||||
|
.....###.#......###.#......###.#.
|
||||||
|
.###.##..#..###.##..#..###.##..#.
|
||||||
|
..#.#...#....#.#...#....#.#...#..
|
||||||
|
....#.#........#.#........#.#....
|
||||||
|
.##...####..##...####..##...####.
|
||||||
|
.##..#...#..##..#...#..##..#...#.
|
||||||
|
.......##.........##.........##..
|
||||||
|
.##.#.####..##.#.####..##.#.####.
|
||||||
|
.##..##.##..##..##.##..##..##.##.
|
||||||
|
.................................
|
||||||
|
.................................
|
||||||
|
.....###.#......###.#......###.#.
|
||||||
|
.###.##..#..###.##..#..###.##..#.
|
||||||
|
..#.#...#....#.#...#....#.#...#..
|
||||||
|
....#.#........#.#........#.#....
|
||||||
|
.##...####..##..S####..##...####.
|
||||||
|
.##..#...#..##..#...#..##..#...#.
|
||||||
|
.......##.........##.........##..
|
||||||
|
.##.#.####..##.#.####..##.#.####.
|
||||||
|
.##..##.##..##..##.##..##..##.##.
|
||||||
|
.................................
|
||||||
|
.................................
|
||||||
|
.....###.#......###.#......###.#.
|
||||||
|
.###.##..#..###.##..#..###.##..#.
|
||||||
|
..#.#...#....#.#...#....#.#...#..
|
||||||
|
....#.#........#.#........#.#....
|
||||||
|
.##...####..##...####..##...####.
|
||||||
|
.##..#...#..##..#...#..##..#...#.
|
||||||
|
.......##.........##.........##..
|
||||||
|
.##.#.####..##.#.####..##.#.####.
|
||||||
|
.##..##.##..##..##.##..##..##.##.
|
||||||
|
.................................
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
This is just a tiny three-map-by-three-map slice of the inexplicably-infinite farm layout; garden plots and rocks repeat as far as you can see. The Elf still starts on the one middle tile marked `S`, though - every other repeated `S` is replaced with a normal garden plot (`.`).
|
||||||
|
|
||||||
|
Here are the number of reachable garden plots in this new infinite version of the example map for different numbers of steps:
|
||||||
|
|
||||||
|
* In exactly `6` steps, he can still reach `*16*` garden plots.
|
||||||
|
* In exactly `10` steps, he can reach any of `*50*` garden plots.
|
||||||
|
* In exactly `50` steps, he can reach `*1594*` garden plots.
|
||||||
|
* In exactly `100` steps, he can reach `*6536*` garden plots.
|
||||||
|
* In exactly `500` steps, he can reach `*167004*` garden plots.
|
||||||
|
* In exactly `1000` steps, he can reach `*668697*` garden plots.
|
||||||
|
* In exactly `5000` steps, he can reach `*16733044*` garden plots.
|
||||||
|
|
||||||
|
However, the step count the Elf needs is much larger! Starting from the garden plot marked `S` on your infinite map, *how many garden plots could the Elf reach in exactly `26501365` steps?*
|
||||||
|
|
||||||
|
Your puzzle answer was `596857397104703`.
|
||||||
|
|
||||||
|
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](21/input).
|
172
2023/day21_step_counter/src/lib.rs
Normal file
172
2023/day21_step_counter/src/lib.rs
Normal file
|
@ -0,0 +1,172 @@
|
||||||
|
use core::fmt::Display;
|
||||||
|
use std::collections::{HashSet, BinaryHeap};
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
|
pub enum ParseError {
|
||||||
|
InvalidTile(u8),
|
||||||
|
NoStartingPosition,
|
||||||
|
TooManyStartingPositions
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Display for ParseError {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
match self {
|
||||||
|
Self::InvalidTile(b) => write!(f, "\"{}\" is not a valid map tile", *b as char),
|
||||||
|
Self::NoStartingPosition => write!(f, "No starting position (marked \"S\") found"),
|
||||||
|
Self::TooManyStartingPositions => write!(f, "More than one starting position (marked \"S\") found"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Hash, PartialEq, Eq, Clone, Copy, Debug)]
|
||||||
|
struct Position(isize, isize);
|
||||||
|
|
||||||
|
impl Position {
|
||||||
|
fn get_neighbours(&self) -> [Self; 4] {
|
||||||
|
[
|
||||||
|
Self(self.0-1, self.1),
|
||||||
|
Self(self.0, self.1-1),
|
||||||
|
Self(self.0+1, self.1),
|
||||||
|
Self(self.0, self.1+1),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Map {
|
||||||
|
rocks: HashSet<Position>,
|
||||||
|
starting: Position,
|
||||||
|
max: Position,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TryFrom<&str> for Map {
|
||||||
|
type Error = ParseError;
|
||||||
|
|
||||||
|
fn try_from(value: &str) -> Result<Self, Self::Error> {
|
||||||
|
let mut rocks = HashSet::new();
|
||||||
|
let mut starting = None;
|
||||||
|
let mut max = Position(0, value.lines().count() as isize);
|
||||||
|
for (y, line) in value.lines().enumerate() {
|
||||||
|
max.0 = max.0.max(line.len() as isize);
|
||||||
|
for (x, b) in line.bytes().enumerate() {
|
||||||
|
match b {
|
||||||
|
b'.' => (),
|
||||||
|
b'#' => _ = rocks.insert(Position(x as isize, y as isize)),
|
||||||
|
b'S' => if starting.is_none() {
|
||||||
|
starting = Some(Position(x as isize, y as isize));
|
||||||
|
} else {
|
||||||
|
return Err(Self::Error::TooManyStartingPositions);
|
||||||
|
},
|
||||||
|
e => return Err(Self::Error::InvalidTile(e)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
match starting {
|
||||||
|
None => Err(Self::Error::NoStartingPosition),
|
||||||
|
Some(s) => Ok(Self{ rocks, starting: s, max })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(PartialEq, Eq)]
|
||||||
|
struct SearchState {
|
||||||
|
steps: usize,
|
||||||
|
position: Position
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PartialOrd for SearchState {
|
||||||
|
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
|
||||||
|
Some(self.cmp(other))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Ord for SearchState {
|
||||||
|
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
|
||||||
|
other.steps.cmp(&self.steps)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn run(input: &str, steps: usize) -> Result<usize, ParseError> {
|
||||||
|
let map = Map::try_from(input)?;
|
||||||
|
Ok(count_positions_after(steps, &map))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn count_positions_after(steps: usize, map: &Map) -> usize {
|
||||||
|
let size = map.max.0.max(map.max.1) as usize;
|
||||||
|
let mut visited_even = HashSet::from([map.starting]);
|
||||||
|
let mut visited_odd = HashSet::new();
|
||||||
|
let mut open_set = BinaryHeap::from([SearchState{ steps: 0, position: map.starting }]);
|
||||||
|
let mut last_step = 0;
|
||||||
|
let mut results = Vec::new();
|
||||||
|
while let Some(state) = open_set.pop() {
|
||||||
|
let (step, position) = (state.steps, state.position);
|
||||||
|
if step == steps {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if step > last_step && (step-1) % size == steps % size {
|
||||||
|
let curr = if step % 2 == 1 {
|
||||||
|
visited_even.len()
|
||||||
|
} else {
|
||||||
|
visited_odd.len()
|
||||||
|
};
|
||||||
|
if results.len() > 2 {
|
||||||
|
let prev_1 = results[results.len()-1];
|
||||||
|
let prev_2 = results[results.len()-2];
|
||||||
|
let prev_3 = results[results.len()-3];
|
||||||
|
if curr+3*prev_2 == 3*prev_1+prev_3 {
|
||||||
|
let remaining_cycles = steps/size - results.len();
|
||||||
|
return curr + remaining_cycles*(curr-prev_1) + triangular(remaining_cycles)*(curr+prev_2-2*prev_1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
results.push(curr);
|
||||||
|
}
|
||||||
|
last_step = step;
|
||||||
|
for neighbour in position.get_neighbours() {
|
||||||
|
if step % 2 == 0 {
|
||||||
|
if !visited_odd.contains(&neighbour) && !map.rocks.contains(&Position(neighbour.0.rem_euclid(map.max.0), neighbour.1.rem_euclid(map.max.1))) {
|
||||||
|
visited_odd.insert(neighbour);
|
||||||
|
open_set.push(SearchState{ steps: step+1, position: neighbour });
|
||||||
|
}
|
||||||
|
} else if !visited_even.contains(&neighbour) && !map.rocks.contains(&Position(neighbour.0.rem_euclid(map.max.0), neighbour.1.rem_euclid(map.max.1))) {
|
||||||
|
visited_even.insert(neighbour);
|
||||||
|
open_set.push(SearchState{ steps: step+1, position: neighbour });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if steps % 2 == 0 {
|
||||||
|
visited_even.len()
|
||||||
|
} else {
|
||||||
|
visited_odd.len()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn triangular(n: usize) -> usize {
|
||||||
|
(n*n+n)/2
|
||||||
|
}
|
||||||
|
|
||||||
|
#[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");
|
||||||
|
let samples = [(6, 16), (10, 50), (50, 1594), (100, 6536), (500, 167004), (1000, 668697), (5000, 16733044)];
|
||||||
|
for (steps, expected) in samples {
|
||||||
|
assert_eq!(run(&sample_input, steps), Ok(expected));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_challenge() {
|
||||||
|
let challenge_input = read_file("tests/challenge_input");
|
||||||
|
let samples = [(64, 3617), (26501365, 596857397104703)];
|
||||||
|
for (steps, expected) in samples {
|
||||||
|
assert_eq!(run(&challenge_input, steps), Ok(expected));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
131
2023/day21_step_counter/tests/challenge_input
Normal file
131
2023/day21_step_counter/tests/challenge_input
Normal file
|
@ -0,0 +1,131 @@
|
||||||
|
...................................................................................................................................
|
||||||
|
...##..##......#...###.....###...#..............#.......................#....................#.#.#........#.............#..........
|
||||||
|
.#..........#...#.#..#....#.#........#.....#..#...........#..................................#.....#.............#..#.#.#.....##...
|
||||||
|
..#....#...................#..........#....#..........#.#..........................#.............#.#.#..............#.#............
|
||||||
|
....#...#............#....#.#.#..#.........#..#......#..#....................#..#.#.............##............#.............##.....
|
||||||
|
..........#............##..#....#.#.............................#.................#....##.##.##....#...##..#.....#.....#.....#.....
|
||||||
|
......#..#...#.#..............#.#......#.#.......#....#........##..#.......#.#.#.....#......#..#.#..#.......#.........##...........
|
||||||
|
...#..#..............#....#.#.......#......#....#.....#.............#........................#.......#..#........#..........##.....
|
||||||
|
...#....#...#..#..#.....#..#....#.#...#.....#...................#.............#...#.....#..#..#..#.........#.....#.......#.........
|
||||||
|
....#....#.......##..........#............#..#.......................................#.#......#.#...#.....#...#........#...#.......
|
||||||
|
.....#...###....#....#...#..............#.........................#.##......................##..#..#.#.##.........#...#............
|
||||||
|
...........#.......#.......#.....#...............#................#.#..##...........##..#.......###.#.#..#...#.#..........#........
|
||||||
|
..#......###..........#.#.......#..#..#..##....#...................#....#........###..#.#.....#...........#..............#..#....#.
|
||||||
|
....#.........#.#....#.........#..#.#.....#...#.........#..#........#...................#....#.#....#..#.#.....#....#...##..#.##...
|
||||||
|
....#..#....#.............#.......#.#...#..............#..........#....#...#........##...#.......#.........#.##............##......
|
||||||
|
.......#.#...........#....#...................................#....#........#...........#.#.###...#.........#.##.#....#...#.#..##..
|
||||||
|
....#..#........#..#..#.#..#.........#......#.............#..............#..................#.....#.#.....#..#.........#...#.......
|
||||||
|
........##...##..#......##...........#.................#.....###..#....#...#..........#.#..............#..#......................#.
|
||||||
|
.#............#.......##...........#.....................#.........#.........................##.....#..###.....#...#..###........#.
|
||||||
|
...........##...#............#......#.................#.....#..#...#...#.......#.........#..##.........#....###.....#.#......##..#.
|
||||||
|
.#....##.......#.......#...#..##..#.#...#............#.#...#......#...........................#.........#........#.........##......
|
||||||
|
..#...#...##.#.......................##...........#..#........#.#.....##..#.##.#..#.......#..#.....#.####.#.......#......#.........
|
||||||
|
.....#.##.#...##.#...........#.................#.....#....#.#..#.......#.........................#.#......#.##..#....#.#........#..
|
||||||
|
.....##.###..#...................#.........................#..#....#..#....................................#..##..#.#...#..#..#.#..
|
||||||
|
.#......#.#......#.............#.##..#.........##...##..........#.........#..#...#.#...........#.....##.......#.............##.#...
|
||||||
|
....#..........#.#....#...#.#....................#.###.........#......##...#.........#............#........#....#..#....##.#...##..
|
||||||
|
.............##.....#...#...#......#.............#............##.....#.......#.#........................#..#..........#...#........
|
||||||
|
..#......##............#...#.........................##..##..............#..#......#.................##........#...............##..
|
||||||
|
..#.......#...#......#...................#........#..#...##............##..#.....#..........................#.#..........#.........
|
||||||
|
...##..#...##..........##....###.........#.......##..................#.......#....................#...........#.#........#.........
|
||||||
|
......#....#......#.......#...#....................#..#........#..#......#..#.#....##.........................#.#....#.#....#....#.
|
||||||
|
.....#......................#................#......##......##.#.........#..##.........#...............##.......#.........#........
|
||||||
|
.#.#......#.#....#..#...#..............#......#..#.#.....#..........##.....#..#........#...#.#.........#..#.....................#..
|
||||||
|
...#.##.#..#..#...#.#................###....................##.....#.#....#.........#......#..#..........##.#....#......#..#.......
|
||||||
|
...#.................#.............#................#.................###..............#.................#..#......#.....#......##.
|
||||||
|
.#.#.....#..#..........#...........#.#............#.##..#......#..##....#.#..###.......##.#.....#.........##...#.#...........#.....
|
||||||
|
..#...#................#....................#..#..........#...............#.....#..#..####................#...............#........
|
||||||
|
..........#..........#..............#........#...##...............#.....#...#...#..##.....#...#...........##.#.....##.#......#.....
|
||||||
|
....#......#.......#...#.......#........#....#.....#..............#....#..##..#......#........#...............#.................#..
|
||||||
|
.#.............#...............#...............#..#...#..#.#...#..#.......#....................#....#........#..##........#........
|
||||||
|
.....................................#....###....#...#.....##.#.......#.........#.#.....#........#...........#...........##......#.
|
||||||
|
.......#.##...#..............#..##..#...#...........#.##..##..#....#..#.........#........#.#.....................#.......#.......#.
|
||||||
|
..#......##...................#..........#........##.....#..........#...#.#....#.#....#............##..............#...#.#.#.......
|
||||||
|
...#.#.##.#.#.......................##......#.......#.........#.........#..........#........#.#.....#.#.............#.........#....
|
||||||
|
.#.#...........#..................#....#......#.#............#....#.#..#...#..#..##.#............................#.#........#.##...
|
||||||
|
..#...#....#...................#....#..........#.......................#.....##..#...#.#.#.......#...#..#.........#......##........
|
||||||
|
.......#.................#...#........#....#.................#......................#...#.........##..................#......#.....
|
||||||
|
..#..#....#..#...............#................#..#.#.....#.#..#.........###.......................#.#..#....#..........#...........
|
||||||
|
......#...#..#...........#......................#..#............................#.....#........#.....##...#............#...........
|
||||||
|
...........................##..#....#....#.....#....#....#...#........#.......#.........#.#..........##...#..................#..#..
|
||||||
|
......#.....................#.....#.......#.#.....#.............#....#...#......#....#..#..........#........#...........#..........
|
||||||
|
..#...#.............#..............#.#....#....#.....#....#...#.#......#.....#.#...........#.#.........#.#..................#..###.
|
||||||
|
..#..............#....##......#.##..................#...##.........#..........#.................#..........#...................#...
|
||||||
|
................#.##...#......##.........#.#...#..####.#.............#...#....#.........#.................................#........
|
||||||
|
....#..........................#.......#...............#......#.......#...###.##.....#.#.#....#..###....#...#...##...........##....
|
||||||
|
...#.#...............#..................#.........#...#.#..............#.....#.......#...#.##...#..#.......#.....#...........#.....
|
||||||
|
.....#.....................#.#.#.....#.#.....#..#..##...#.....#...........#...##........#..#.......#.#...#....#..#............#....
|
||||||
|
..#..........#....##..#.....###.#...............................#.#.##.#...#....##........#...#.....#....#............#.......#....
|
||||||
|
.#...........#...#..#.....#..........#............#.......##......#.................#.#...#..##........#...............#...........
|
||||||
|
.#................#........##.#.#.....#.#.............#.....#..#..##...............#..#................#.......#...#...##.......##.
|
||||||
|
.#........#.##........##..#.#.##.....#..###..#......##...#......#..........#...............#.....#....#......#.....................
|
||||||
|
............#.........#..............#.....#..#......................#...#.##.##...###..#..........###........###..................
|
||||||
|
...........#...##.............#......#.....#.#...#...#.#..#....#..#............#....#..#.....#.#.........#.....#..#.###....#.......
|
||||||
|
.........#........#.......#..#..##..#........#.#.#...........#....................##..#....#..#.....##.......##...##...............
|
||||||
|
.......#....##..........##.....#...##....#.........#..#...................#......###.....#........#.....................#.#.#......
|
||||||
|
.................................................................S.................................................................
|
||||||
|
.....#...........#...#....#...#..#.........#.......##.#.............................#...#....#......#......#...#.#......#....#.....
|
||||||
|
........###...#.......................#...........#.....#.#.........#.#......#...#.....#..#...###.....#.#....#..........#..........
|
||||||
|
...............#.#............#.#......#...#..#.......#..#.#..#....##.#..#....#...............#.##.#..#...#...#..#.................
|
||||||
|
.............#.##..........#........#.#........###.....#..............#.......#..........##...........#........#...#...............
|
||||||
|
...........#.#.#........#......###.....#.#......#.#..##..#..#...#...##.#.#...##.......#........#..#.#.##...###...........#.........
|
||||||
|
..........##..............#......#.............#..#.#....#..#.....#.#...#..........##............#...#.##.....#.#..#...............
|
||||||
|
.#.#...............#.#............##.......#...#..#....#.....#........#.#..###...#.....#.........#................#..#.............
|
||||||
|
.............#...#........#....#....#..........##.#....#......#.....#.........#..#........#.......###....#.#....#....##............
|
||||||
|
...#............#.#......#...#....#..............#.....#..##....#.....#....#.....#...#...#.#..#.........#.#.........#..............
|
||||||
|
..............#.......#...........#..............#.#.......#..#.#......#...##.......#................#...#.....#...#...............
|
||||||
|
...##...........................#...#...#.......#............#.#.....#...#....#..#......#..#.##....#.#...#...#.................#.#.
|
||||||
|
...#....#...........#.........##...#............#...............#...................................##..#......#..#..............#.
|
||||||
|
...##.#.#.............#....#.##.#........#.....#.#...#.....##...........#.....................#...#..#......#............##.....#..
|
||||||
|
...#..#...#...............#.#......#....#.#.#......#...................#......#.....##....#....#....##...#......#..............#...
|
||||||
|
......#..#.........#.................#...#................#.........#..................................................#....#......
|
||||||
|
.#..........#..........#..................#.#...#....#....#.#.........#..#...#........#......#.............#....................#..
|
||||||
|
........#............#........#.......##......##....#................#.......#....#.#.....#............#.#.#...............###.....
|
||||||
|
.##........#..........#...#......##..#.##.#.....##.........................#.....##.#...#......#.#......#..#..........#............
|
||||||
|
....#....................#...#.......#...#.......#.....#......#...#..#...#......#.#..#...##.##..#.....##...........#..#.###........
|
||||||
|
.#.....#........#..............#...#...#.........#.#................#.#.............##.#....#..#.....................#.....#..###..
|
||||||
|
......#...#.#..#.............##.#........#.....................#........#....#...........#....##......................#............
|
||||||
|
..#.....##...#..#.#.........#.#.......#.#..#......#..........#.##....#..#..................#.........#..#........#....##...........
|
||||||
|
..#...#.#....#.#...................##......##...........#...#.............#..........#.##..#.#......#..................#..#.#...##.
|
||||||
|
...##...#........#.#.........#...#.....#.#...##...#...#..#.#.........#.....#..#....#.###...#........#.............#.........#....#.
|
||||||
|
.........#...#.#...#.#.................#............#........................#.#.....#.........#................#.....#..#......#..
|
||||||
|
...........#.#..#.............##........#..........#....#...........#....#.....#....#....#.#......##.........#..##....#..##........
|
||||||
|
.........#..................................#..#...............#...#..#...#...#..#......#.#..#.............#...........#.#..#...##.
|
||||||
|
.#.#......#..#.......#.##........#......#....#................#...#...##..##....#.....#..........#.........#....#..#.#.........#...
|
||||||
|
.....#.....#.........#............#....#.....................#....#.##...#......................#................#.#.#...#.........
|
||||||
|
.....#.............##..#..........#..#..............##..#.................##........###.....#.#.........#.#.#...............#......
|
||||||
|
.#.#.#...#.#..............#...............#...............#..#.....#......#..............................#.......#.#...#.#...#.....
|
||||||
|
.................#........#...............#.........................................#......................#....#............#...#.
|
||||||
|
.#...#.###...........#...#..##...............#.........#...##....................#...........#...............#....##...........#.#.
|
||||||
|
..###...#.#.........##.................#.#.....#..##...........#....##........#...#...................##..##...#................#..
|
||||||
|
...#.................#.....#...........#....#...##...#.......#............#.....#.#........#........#...#...##...#.##..............
|
||||||
|
.......#....#.........#.#.....#.#.......#.....#....#...#.............#.....#.....#.##.....................#.###...........#........
|
||||||
|
................#....#..#.......#.............#......#.......#.................#.#................#..........#.....##...#..#....#..
|
||||||
|
........#...#...#.#......##......#.........#.......................#.........#...#.....................#..........#.#..#...#.......
|
||||||
|
....#.......##......##....##.................#.....#.#.#....#...#...........#.......................#........#....#....#.....#...#.
|
||||||
|
.#..##..##.........#......#.........#.......#....#....#...#.....#..#.....#.#............................#...#..................#.#.
|
||||||
|
...#......#............##.....##.............##.................#..#....#.#...#....#......................##....#.....#........#...
|
||||||
|
........#....#....#..........#.###....#................#..##......#..#...#..#......#..........##...............#..#.........#...#..
|
||||||
|
.....#...#.##.....#....#.##.........#............##....#..#.#.....#.............#...................#..#............#..#..#.#....#.
|
||||||
|
.....#..#.........##..#...........#....#............#.#...........#..............##.......#.#...........#..####.....##.#.##........
|
||||||
|
...#.#.#.##.#.#..#.....#........###..#............#........##......##.#..........................####........##.#.....#......#.....
|
||||||
|
.##.#.#...##..#........##....#........#............#...#...#......#....#....##..#...........#.#.........#.##...#...#...#...#.#.....
|
||||||
|
......#.#..#.#........##.#....#.#...#.###..#...........#...................#.................#.#.#............##.#...#.#.........#.
|
||||||
|
........#.#....#...#...#..........#.#..#..#...........#..#...#.....##......#.....................##..#........#.....#.#.....#....#.
|
||||||
|
..#.......##....##............##...............................#......#.#..#.............#..........................#....#.........
|
||||||
|
.......#....#................#...........#...##................#...#.#....#...............#....##.......................#.#.....#..
|
||||||
|
..........#...........#..#..#.....#...........##...........#......#.#.#.#..........#..........#.....#......................###.....
|
||||||
|
....#.......##...........#..........#..###.#.........................#....#..........#.#.........#......#............#..#.....#..#.
|
||||||
|
...#.#...#...#.............#.......#...#.##..............................#........##.......##..#...#......................#........
|
||||||
|
...........##.............#....##....#.#...#.#..............#..#..................#.......#......#.......#.................#..#....
|
||||||
|
.#.##..#......#...#..#........#.......#.#.#....#...............#........................#..........#...............................
|
||||||
|
........#...........#....#...#...##..#.#....###................#...#.................#..................#.......#....#........#..#.
|
||||||
|
.........#.###.#....#..#..##..........#.#.......#............................#..##....#.....#....#....#.#...##......##.............
|
||||||
|
..#.#..##.#........#..#.#...#........#...#...#.....................##...........#.....#...#.#.#...#.......#..#..#.........#..#..#..
|
||||||
|
.....#..........####....##..##......#.............#...#...........#........#..........#.............###...#.#.#...#................
|
||||||
|
..#.....#...#....#.#.........#....#..#.......##.....#.............#........#............#...###.........#...#......................
|
||||||
|
.##..............#..#....#..#......#....##..#......#.###.#..................#...............#.#..#..#.##..........#............#.#.
|
||||||
|
..#..#..#.....................#.#..............##...#.....#....................#..##...#.........#...........#..##.........#....#..
|
||||||
|
....#...............#.......#.#....##....#..#..........................#.......#.##...........#.......#....#.#........#..#.........
|
||||||
|
.....##.......#.................................#........#..................#..#.#......#....#..#....#...#.........................
|
||||||
|
...................................................................................................................................
|
11
2023/day21_step_counter/tests/sample_input
Normal file
11
2023/day21_step_counter/tests/sample_input
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
...........
|
||||||
|
.....###.#.
|
||||||
|
.###.##..#.
|
||||||
|
..#.#...#..
|
||||||
|
....#.#....
|
||||||
|
.##..S####.
|
||||||
|
.##..#...#.
|
||||||
|
.......##..
|
||||||
|
.##.#.####.
|
||||||
|
.##..##.##.
|
||||||
|
...........
|
Loading…
Add table
Add a link
Reference in a new issue