1
1
mirror of https://github.com/theoludwig/advent_of_code_2023.git synced 2024-07-12 13:20:11 +02:00

docs: add day 8 - part 2 instructions

This commit is contained in:
Théo LUDWIG 2024-02-08 21:04:22 +01:00
parent 68078034e6
commit 23bc51e78c
Signed by: theoludwig
GPG Key ID: ADFE5A563D718F3B
2 changed files with 49 additions and 1 deletions

View File

@ -14,6 +14,17 @@
<a href="https://conventionalcommits.org"><img src="https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg" alt="Conventional Commits" /></a>
</p>
## Days Progress
- [Day 1 (`**`)](./day_1)
- [Day 2 (`**`)](./day_2)
- [Day 3 (`**`)](./day_3)
- [Day 4 (`**`)](./day_4)
- [Day 5 (`**`)](./day_5)
- [Day 6 (`**`)](./day_6)
- [Day 7 (`*`)](./day_7)
- [Day 8 (`*`)](./day_8)
## Getting Started
### Prerequisites
@ -29,7 +40,7 @@ The project is **tested** against the following Rust versions:
#### External Linting Tools (optional)
**External linting tools** are used to ensure a consistent code style and commit message format. They are **used in the Continuous Integration (CI)** pipeline and **can be optionally used locally**.
**External linting tools** are used to ensure a consistent code style (external to Rust) and commit message format. They are **used in the Continuous Integration (CI)** pipeline and **can be optionally used locally**.
They have to be installed using [Node.js](https://nodejs.org/) >= v20.0.0 and [npm](https://www.npmjs.com/) >= v10.0.0.

View File

@ -39,3 +39,40 @@ ZZZ = (ZZZ, ZZZ)
```
Starting at `AAA`, follow the left/right instructions. **How many steps are required to reach `ZZZ`?**
## Instructions - Part 2
The sandstorm is upon you and you aren't any closer to escaping the wasteland. You had the camel follow the instructions, but you've barely left your starting position. It's going to take **significantly more steps** to escape!
What if the map isn't for people - what if the map is for **ghosts**? Are ghosts even bound by the laws of spacetime? Only one way to find out.
After examining the maps a bit longer, your attention is drawn to a curious fact: the number of nodes with names ending in `A` is equal to the number ending in `Z`! If you were a ghost, you'd probably just **start at every node that ends with `A`** and follow all of the paths at the same time until they all simultaneously end up at nodes that end with `Z`.
For example:
```txt
LR
11A = (11B, XXX)
11B = (XXX, 11Z)
11Z = (11B, XXX)
22A = (22B, XXX)
22B = (22C, 22C)
22C = (22Z, 22Z)
22Z = (22B, 22B)
XXX = (XXX, XXX)
```
Here, there are two starting nodes, `11A` and `22A` (because they both end with `A`). As you follow each left/right instruction, use that instruction to **simultaneously** navigate away from both nodes you're currently on. Repeat this process until **all** of the nodes you're currently on end with `Z`. (If only some of the nodes you're on end with `Z`, they act like any other node and you continue as normal.) In this example, you would proceed as follows:
- Step 0: You are at `11A` and `22A`.
- Step 1: You choose all of the **left** paths, leading you to `11B` and `22B`.
- Step 2: You choose all of the **right** paths, leading you to **`11Z`** and `22C`.
- Step 3: You choose all of the **left** paths, leading you to `11B` and **`22Z`**.
- Step 4: You choose all of the **right** paths, leading you to **`11Z`** and `22B`.
- Step 5: You choose all of the **left** paths, leading you to `11B` and `22C`.
- Step 6: You choose all of the **right** paths, leading you to **`11Z`** and **`22Z`**.
So, in this example, you end up entirely on nodes that end in `Z` after **`6`** steps.
Simultaneously start on every node that ends with `A`. **How many steps does it take before you're only on nodes that end with `Z`?**