Mercurial > repos > other > adventofcode2023
annotate day10.txt @ 18:ddb69833346c
Implement day 11 distance finding in space
"shortest distance" is simplified by it being cardinal directions,
so it's the same as taking the right-angle between them.
The Part 1 space expansion was quite clean, but the Part 2
approach generalises it to something even nicer.
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Mon, 11 Dec 2023 20:08:47 +0000 |
parents | 92144824cbb7 |
children | 1e16a25a9553 |
rev | line source |
---|---|
16
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1 --- Day 10: Pipe Maze --- |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
2 |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
3 You use the hang glider to ride the hot air from Desert Island all the way up to the floating metal island. This island is surprisingly cold and there definitely aren't any thermals to glide on, so you leave your hang glider behind. |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
4 |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
5 You wander around for a while, but you don't find any people or animals. However, you do occasionally find signposts labeled "Hot Springs" pointing in a seemingly consistent direction; maybe you can find someone at the hot springs and ask them where the desert-machine parts are made. |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
6 |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
7 The landscape here is alien; even the flowers and trees are made of metal. As you stop to admire some metal grass, you notice something metallic scurry away in your peripheral vision and jump into a big pipe! It didn't look like any animal you've ever seen; if you want a better look, you'll need to get ahead of it. |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
8 |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
9 Scanning the area, you discover that the entire field you're standing on is densely packed with pipes; it was hard to tell at first because they're the same metallic silver color as the "ground". You make a quick sketch of all of the surface pipes you can see (your puzzle input). |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
10 |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
11 The pipes are arranged in a two-dimensional grid of tiles: |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
12 |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
13 | is a vertical pipe connecting north and south. |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
14 - is a horizontal pipe connecting east and west. |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
15 L is a 90-degree bend connecting north and east. |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
16 J is a 90-degree bend connecting north and west. |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
17 7 is a 90-degree bend connecting south and west. |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
18 F is a 90-degree bend connecting south and east. |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
19 . is ground; there is no pipe in this tile. |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
20 S is the starting position of the animal; there is a pipe on this tile, but your sketch doesn't show what shape the pipe has. |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
21 |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
22 Based on the acoustics of the animal's scurrying, you're confident the pipe that contains the animal is one large, continuous loop. |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
23 |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
24 For example, here is a square loop of pipe: |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
25 |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
26 ..... |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
27 .F-7. |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
28 .|.|. |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
29 .L-J. |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
30 ..... |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
31 |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
32 If the animal had entered this loop in the northwest corner, the sketch would instead look like this: |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
33 |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
34 ..... |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
35 .S-7. |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
36 .|.|. |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
37 .L-J. |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
38 ..... |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
39 |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
40 In the above diagram, the S tile is still a 90-degree F bend: you can tell because of how the adjacent pipes connect to it. |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
41 |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
42 Unfortunately, there are also many pipes that aren't connected to the loop! This sketch shows the same loop as above: |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
43 |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
44 -L|F7 |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
45 7S-7| |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
46 L|7|| |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
47 -L-J| |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
48 L|-JF |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
49 |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
50 In the above diagram, you can still figure out which pipes form the main loop: they're the ones connected to S, pipes those pipes connect to, pipes those pipes connect to, and so on. Every pipe in the main loop connects to its two neighbors (including S, which will have exactly two pipes connecting to it, and which is assumed to connect back to those two pipes). |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
51 |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
52 Here is a sketch that contains a slightly more complex main loop: |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
53 |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
54 ..F7. |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
55 .FJ|. |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
56 SJ.L7 |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
57 |F--J |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
58 LJ... |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
59 |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
60 Here's the same example sketch with the extra, non-main-loop pipe tiles also shown: |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
61 |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
62 7-F7- |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
63 .FJ|7 |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
64 SJLL7 |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
65 |F--J |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
66 LJ.LJ |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
67 |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
68 If you want to get out ahead of the animal, you should find the tile in the loop that is farthest from the starting position. Because the animal is in the pipe, it doesn't make sense to measure this by direct distance. Instead, you need to find the tile that would take the longest number of steps along the loop to reach from the starting point - regardless of which way around the loop the animal went. |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
69 |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
70 In the first example with the square loop: |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
71 |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
72 ..... |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
73 .S-7. |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
74 .|.|. |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
75 .L-J. |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
76 ..... |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
77 |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
78 You can count the distance each tile in the loop is from the starting point like this: |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
79 |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
80 ..... |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
81 .012. |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
82 .1.3. |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
83 .234. |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
84 ..... |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
85 |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
86 In this example, the farthest point from the start is 4 steps away. |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
87 |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
88 Here's the more complex loop again: |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
89 |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
90 ..F7. |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
91 .FJ|. |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
92 SJ.L7 |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
93 |F--J |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
94 LJ... |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
95 |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
96 Here are the distances for each tile on that loop: |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
97 |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
98 ..45. |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
99 .236. |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
100 01.78 |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
101 14567 |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
102 23... |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
103 |
9b1d04091335
Path finding through the pipes for day 10
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
104 Find the single giant loop starting at S. How many steps along the loop does it take to get from the starting position to the point farthest from the starting position? |
17
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
105 |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
106 --- Part Two --- |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
107 |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
108 You quickly reach the farthest point of the loop, but the animal never emerges. Maybe its nest is within the area enclosed by the loop? |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
109 |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
110 To determine whether it's even worth taking the time to search for such a nest, you should calculate how many tiles are contained within the loop. For example: |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
111 |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
112 ........... |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
113 .S-------7. |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
114 .|F-----7|. |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
115 .||.....||. |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
116 .||.....||. |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
117 .|L-7.F-J|. |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
118 .|..|.|..|. |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
119 .L--J.L--J. |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
120 ........... |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
121 |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
122 The above loop encloses merely four tiles - the two pairs of . in the southwest and southeast (marked I below). The middle . tiles (marked O below) are not in the loop. Here is the same loop again with those regions marked: |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
123 |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
124 ........... |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
125 .S-------7. |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
126 .|F-----7|. |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
127 .||OOOOO||. |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
128 .||OOOOO||. |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
129 .|L-7OF-J|. |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
130 .|II|O|II|. |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
131 .L--JOL--J. |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
132 .....O..... |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
133 |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
134 In fact, there doesn't even need to be a full tile path to the outside for tiles to count as outside the loop - squeezing between pipes is also allowed! Here, I is still within the loop and O is still outside the loop: |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
135 |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
136 .......... |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
137 .S------7. |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
138 .|F----7|. |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
139 .||OOOO||. |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
140 .||OOOO||. |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
141 .|L-7F-J|. |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
142 .|II||II|. |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
143 .L--JL--J. |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
144 .......... |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
145 |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
146 In both of the above examples, 4 tiles are enclosed by the loop. |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
147 |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
148 Here's a larger example: |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
149 |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
150 .F----7F7F7F7F-7.... |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
151 .|F--7||||||||FJ.... |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
152 .||.FJ||||||||L7.... |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
153 FJL7L7LJLJ||LJ.L-7.. |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
154 L--J.L7...LJS7F-7L7. |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
155 ....F-J..F7FJ|L7L7L7 |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
156 ....L7.F7||L7|.L7L7| |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
157 .....|FJLJ|FJ|F7|.LJ |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
158 ....FJL-7.||.||||... |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
159 ....L---J.LJ.LJLJ... |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
160 |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
161 The above sketch has many random bits of ground, some of which are in the loop (I) and some of which are outside it (O): |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
162 |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
163 OF----7F7F7F7F-7OOOO |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
164 O|F--7||||||||FJOOOO |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
165 O||OFJ||||||||L7OOOO |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
166 FJL7L7LJLJ||LJIL-7OO |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
167 L--JOL7IIILJS7F-7L7O |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
168 OOOOF-JIIF7FJ|L7L7L7 |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
169 OOOOL7IF7||L7|IL7L7| |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
170 OOOOO|FJLJ|FJ|F7|OLJ |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
171 OOOOFJL-7O||O||||OOO |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
172 OOOOL---JOLJOLJLJOOO |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
173 |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
174 In this larger example, 8 tiles are enclosed by the loop. |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
175 |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
176 Any tile that isn't part of the main loop can count as being enclosed by the loop. Here's another example with many bits of junk pipe lying around that aren't connected to the main loop at all: |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
177 |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
178 FF7FSF7F7F7F7F7F---7 |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
179 L|LJ||||||||||||F--J |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
180 FL-7LJLJ||||||LJL-77 |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
181 F--JF--7||LJLJ7F7FJ- |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
182 L---JF-JLJ.||-FJLJJ7 |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
183 |F|F-JF---7F7-L7L|7| |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
184 |FFJF7L7F-JF7|JL---7 |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
185 7-L-JL7||F7|L7F-7F7| |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
186 L.L7LFJ|||||FJL7||LJ |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
187 L7JLJL-JLJLJL--JLJ.L |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
188 |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
189 Here are just the tiles that are enclosed by the loop marked with I: |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
190 |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
191 FF7FSF7F7F7F7F7F---7 |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
192 L|LJ||||||||||||F--J |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
193 FL-7LJLJ||||||LJL-77 |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
194 F--JF--7||LJLJIF7FJ- |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
195 L---JF-JLJIIIIFJLJJ7 |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
196 |F|F-JF---7IIIL7L|7| |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
197 |FFJF7L7F-JF7IIL---7 |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
198 7-L-JL7||F7|L7F-7F7| |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
199 L.L7LFJ|||||FJL7||LJ |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
200 L7JLJL-JLJLJL--JLJ.L |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
201 |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
202 In this last example, 10 tiles are enclosed by the loop. |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
203 |
92144824cbb7
Add "inside the loop" counting for day 10 part 2
IBBoard <dev@ibboard.co.uk>
parents:
16
diff
changeset
|
204 Figure out whether you have time to search for the nest by calculating the area within the loop. How many tiles are enclosed by the loop? |