@@ -118,3 +118,109 @@ Here are the distances for each tile on that loop:
118118```
119119Find the single giant loop starting at ` S ` . ** How many steps along the loop does it take to get from the starting
120120position to the point farthest from the starting position** ?
121+
122+ # Part Two
123+ You quickly reach the farthest point of the loop, but the animal never emerges. Maybe its nest is ** within the area
124+ enclosed by the loop** ?
125+
126+ To determine whether it's even worth taking the time to search for such a nest, you should calculate how many tiles are
127+ contained within the loop. For example:
128+ ```
129+ ...........
130+ .S-------7.
131+ .|F-----7|.
132+ .||.....||.
133+ .||.....||.
134+ .|L-7.F-J|.
135+ .|..|.|..|.
136+ .L--J.L--J.
137+ ...........
138+ ```
139+ The above loop encloses merely ** four tiles** - the two pairs of ` . ` in the southwest and southeast (marked ` I ` below).
140+ The middle ` . ` tiles (marked ` O ` below) are not in the loop. Here is the same loop again with those regions marked:
141+ ```
142+ ...........
143+ .S-------7.
144+ .|F-----7|.
145+ .||OOOOO||.
146+ .||OOOOO||.
147+ .|L-7OF-J|.
148+ .|II|O|II|.
149+ .L--JOL--J.
150+ .....O.....
151+ ```
152+ In fact, there doesn't even need to be a full tile path to the outside for tiles to count as outside the loop -
153+ squeezing between pipes is also allowed! Here, ` I ` is still within the loop and ` O ` is still outside the loop:
154+ ```
155+ ..........
156+ .S------7.
157+ .|F----7|.
158+ .||OOOO||.
159+ .||OOOO||.
160+ .|L-7F-J|.
161+ .|II||II|.
162+ .L--JL--J.
163+ ..........
164+ ```
165+ In both of the above examples, ** ` 4 ` ** tiles are enclosed by the loop.
166+
167+ Here's a larger example:
168+ ```
169+ .F----7F7F7F7F-7....
170+ .|F--7||||||||FJ....
171+ .||.FJ||||||||L7....
172+ FJL7L7LJLJ||LJ.L-7..
173+ L--J.L7...LJS7F-7L7.
174+ ....F-J..F7FJ|L7L7L7
175+ ....L7.F7||L7|.L7L7|
176+ .....|FJLJ|FJ|F7|.LJ
177+ ....FJL-7.||.||||...
178+ ....L---J.LJ.LJLJ...
179+ ```
180+ The above sketch has many random bits of ground, some of which are in the loop (` I ` ) and some of which are outside it
181+ (` O ` ):
182+ ```
183+ OF----7F7F7F7F-7OOOO
184+ O|F--7||||||||FJOOOO
185+ O||OFJ||||||||L7OOOO
186+ FJL7L7LJLJ||LJIL-7OO
187+ L--JOL7IIILJS7F-7L7O
188+ OOOOF-JIIF7FJ|L7L7L7
189+ OOOOL7IF7||L7|IL7L7|
190+ OOOOO|FJLJ|FJ|F7|OLJ
191+ OOOOFJL-7O||O||||OOO
192+ OOOOL---JOLJOLJLJOOO
193+ ```
194+ In this larger example, ** ` 8 ` ** tiles are enclosed by the loop.
195+
196+ Any tile that isn't part of the main loop can count as being enclosed by the loop. Here's another example with many
197+ bits of junk pipe lying around that aren't connected to the main loop at all:
198+ ```
199+ FF7FSF7F7F7F7F7F---7
200+ L|LJ||||||||||||F--J
201+ FL-7LJLJ||||||LJL-77
202+ F--JF--7||LJLJ7F7FJ-
203+ L---JF-JLJ.||-FJLJJ7
204+ |F|F-JF---7F7-L7L|7|
205+ |FFJF7L7F-JF7|JL---7
206+ 7-L-JL7||F7|L7F-7F7|
207+ L.L7LFJ|||||FJL7||LJ
208+ L7JLJL-JLJLJL--JLJ.L
209+ ```
210+ Here are just the tiles that are ** enclosed by the loop** marked with ` I ` :
211+ ```
212+ FF7FSF7F7F7F7F7F---7
213+ L|LJ||||||||||||F--J
214+ FL-7LJLJ||||||LJL-77
215+ F--JF--7||LJLJIF7FJ-
216+ L---JF-JLJIIIIFJLJJ7
217+ |F|F-JF---7IIIL7L|7|
218+ |FFJF7L7F-JF7IIL---7
219+ 7-L-JL7||F7|L7F-7F7|
220+ L.L7LFJ|||||FJL7||LJ
221+ L7JLJL-JLJLJL--JLJ.L
222+ ```
223+ In this last example, ** ` 10 ` ** tiles are enclosed by the loop.
224+
225+ Figure out whether you have time to search for the nest by calculating the area within the loop. ** How many tiles are
226+ enclosed by the loop** ?
0 commit comments