Mercurial > repos > other > adventofcode2023
annotate day8.txt @ 35:ca54f9702892
Day 24 part 2 instructions and partial solution
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Thu, 18 Apr 2024 19:54:59 +0100 |
parents | 1e16a25a9553 |
children |
rev | line source |
---|---|
11 | 1 --- Day 8: Haunted Wasteland --- |
2 | |
19
1e16a25a9553
Strip down the text to just the puzzle, not the fluff
IBBoard <dev@ibboard.co.uk>
parents:
11
diff
changeset
|
3 You have a map that describes a list of nodes. It seems like you're meant to use the left/right instructions to navigate the network. |
11 | 4 |
19
1e16a25a9553
Strip down the text to just the puzzle, not the fluff
IBBoard <dev@ibboard.co.uk>
parents:
11
diff
changeset
|
5 AAA is where you are now, and you have to follow the left/right instructions until you reach ZZZ. |
11 | 6 |
7 This format defines each node of the network individually. For example: | |
8 | |
9 RL | |
10 | |
11 AAA = (BBB, CCC) | |
12 BBB = (DDD, EEE) | |
13 CCC = (ZZZ, GGG) | |
14 DDD = (DDD, DDD) | |
15 EEE = (EEE, EEE) | |
16 GGG = (GGG, GGG) | |
17 ZZZ = (ZZZ, ZZZ) | |
18 | |
19 Starting with AAA, you need to look up the next element based on the next left/right instruction in your input. In this example, start with AAA and go right (R) by choosing the right element of AAA, CCC. Then, L means to choose the left element of CCC, ZZZ. By following the left/right instructions, you reach ZZZ in 2 steps. | |
20 | |
21 Of course, you might not find ZZZ right away. If you run out of left/right instructions, repeat the whole sequence of instructions as necessary: RL really means RLRLRLRLRLRLRLRL... and so on. For example, here is a situation that takes 6 steps to reach ZZZ: | |
22 | |
23 LLR | |
24 | |
25 AAA = (BBB, BBB) | |
26 BBB = (AAA, ZZZ) | |
27 ZZZ = (ZZZ, ZZZ) | |
28 | |
29 Starting at AAA, follow the left/right instructions. How many steps are required to reach ZZZ? | |
30 | |
31 --- Part Two --- | |
32 | |
19
1e16a25a9553
Strip down the text to just the puzzle, not the fluff
IBBoard <dev@ibboard.co.uk>
parents:
11
diff
changeset
|
33 The number of nodes with names ending in A is equal to the number ending in Z! You actually have to 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. |
11 | 34 |
35 For example: | |
36 | |
37 LR | |
38 | |
39 11A = (11B, XXX) | |
40 11B = (XXX, 11Z) | |
41 11Z = (11B, XXX) | |
42 22A = (22B, XXX) | |
43 22B = (22C, 22C) | |
44 22C = (22Z, 22Z) | |
45 22Z = (22B, 22B) | |
46 XXX = (XXX, XXX) | |
47 | |
48 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: | |
49 | |
50 Step 0: You are at 11A and 22A. | |
51 Step 1: You choose all of the left paths, leading you to 11B and 22B. | |
52 Step 2: You choose all of the right paths, leading you to 11Z and 22C. | |
53 Step 3: You choose all of the left paths, leading you to 11B and 22Z. | |
54 Step 4: You choose all of the right paths, leading you to 11Z and 22B. | |
55 Step 5: You choose all of the left paths, leading you to 11B and 22C. | |
56 Step 6: You choose all of the right paths, leading you to 11Z and 22Z. | |
57 | |
58 So, in this example, you end up entirely on nodes that end in Z after 6 steps. | |
59 | |
60 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? |