@@ -41,3 +41,44 @@ BBB = (AAA, ZZZ)
4141ZZZ = (ZZZ, ZZZ)
4242```
4343Starting at ` AAA ` , follow the left/right instructions. ** How many steps are required to reach ` ZZZ ` ** ?
44+
45+ # Part Two
46+ The sandstorm is upon you and you aren't any closer to escaping the wasteland. You had the camel follow the
47+ instructions, but you've barely left your starting position. It's going to take ** significantly more steps** to escape!
48+
49+ What if the map isn't for people - what if the map is for ** ghosts** ? Are ghosts even bound by the laws of spacetime?
50+ Only one way to find out.
51+
52+ After examining the maps a bit longer, your attention is drawn to a curious fact: the number of nodes with names ending
53+ 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
54+ with ` A ` ** and follow all of the paths at the same time until they all simultaneously end up at nodes that end with ` Z ` .
55+
56+ For example:
57+ ```
58+ LR
59+
60+ 11A = (11B, XXX)
61+ 11B = (XXX, 11Z)
62+ 11Z = (11B, XXX)
63+ 22A = (22B, XXX)
64+ 22B = (22C, 22C)
65+ 22C = (22Z, 22Z)
66+ 22Z = (22B, 22B)
67+ XXX = (XXX, XXX)
68+ ```
69+ Here, there are two starting nodes, ` 11A ` and ` 22A ` (because they both end with ` A ` ). As you follow each left/right
70+ instruction, use that instruction to ** simultaneously** navigate away from both nodes you're currently on. Repeat this
71+ 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 ` ,
72+ they act like any other node and you continue as normal.) In this example, you would proceed as follows:
73+ * Step ` 0 ` : You are at ` 11A ` and ` 22A ` .
74+ * Step ` 1 ` : You choose all of the ** left** paths, leading you to ` 11B ` and ` 22B ` .
75+ * Step ` 2 ` : You choose all of the ** right** paths, leading you to ** ` 11Z ` ** and ` 22C ` .
76+ * Step ` 3 ` : You choose all of the ** left** paths, leading you to ` 11B ` and ** ` 22Z ` ** .
77+ * Step ` 4 ` : You choose all of the ** right** paths, leading you to ** ` 11Z ` ** and ` 22B ` .
78+ * Step ` 5 ` : You choose all of the ** left** paths, leading you to ` 11B ` and ` 22C ` .
79+ * Step ` 6 ` : You choose all of the ** right** paths, leading you to ** ` 11Z ` ** and ** ` 22Z ` ** .
80+
81+ So, in this example, you end up entirely on nodes that end in ` Z ` after ** ` 6 ` ** steps.
82+
83+ Simultaneously start on every node that ends with ` A ` . ** How many steps does it take before you're only on nodes that
84+ end with ` Z ` ** ?
0 commit comments