comparison 2017/day13/problem @ 34:049fb8e56025

Add problem statements and inputs
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Tue, 09 Jan 2018 21:51:44 -0500
parents
children
comparison
equal deleted inserted replaced
33:bc652fa0a645 34:049fb8e56025
1 --- Day 13: Packet Scanners ---
2
3 You need to cross a vast firewall. The firewall consists of several
4 layers, each with a security scanner that moves back and forth across
5 the layer. To succeed, you must not be detected by a scanner.
6
7 By studying the firewall briefly, you are able to record (in your
8 puzzle input) the depth of each layer and the range of the scanning
9 area for the scanner within it, written as depth: range. Each layer
10 has a thickness of exactly 1. A layer at depth 0 begins immediately
11 inside the firewall; a layer at depth 1 would start immediately after
12 that.
13
14 For example, suppose you've recorded the following:
15
16 0: 3
17 1: 2
18 4: 4
19 6: 4
20
21 This means that there is a layer immediately inside the firewall (with
22 range 3), a second layer immediately after that (with range 2), a
23 third layer which begins at depth 4 (with range 4), and a fourth layer
24 which begins at depth 6 (also with range 4). Visually, it might look
25 like this:
26
27 0 1 2 3 4 5 6
28 [ ] [ ] ... ... [ ] ... [ ]
29 [ ] [ ] [ ] [ ]
30 [ ] [ ] [ ]
31 [ ] [ ]
32
33 Within each layer, a security scanner moves back and forth within its
34 range. Each security scanner starts at the top and moves down until it
35 reaches the bottom, then moves up until it reaches the top, and
36 repeats. A security scanner takes one picosecond to move one step.
37 Drawing scanners as S, the first few picoseconds look like this:
38
39
40 Picosecond 0:
41 0 1 2 3 4 5 6
42 [S] [S] ... ... [S] ... [S]
43 [ ] [ ] [ ] [ ]
44 [ ] [ ] [ ]
45 [ ] [ ]
46
47 Picosecond 1:
48 0 1 2 3 4 5 6
49 [ ] [ ] ... ... [ ] ... [ ]
50 [S] [S] [S] [S]
51 [ ] [ ] [ ]
52 [ ] [ ]
53
54 Picosecond 2:
55 0 1 2 3 4 5 6
56 [ ] [S] ... ... [ ] ... [ ]
57 [ ] [ ] [ ] [ ]
58 [S] [S] [S]
59 [ ] [ ]
60
61 Picosecond 3:
62 0 1 2 3 4 5 6
63 [ ] [ ] ... ... [ ] ... [ ]
64 [S] [S] [ ] [ ]
65 [ ] [ ] [ ]
66 [S] [S]
67
68 Your plan is to hitch a ride on a packet about to move through the
69 firewall. The packet will travel along the top of each layer, and it
70 moves at one layer per picosecond. Each picosecond, the packet moves
71 one layer forward (its first move takes it into layer 0), and then the
72 scanners move one step. If there is a scanner at the top of the layer
73 as your packet enters it, you are caught. (If a scanner moves into the
74 top of its layer while you are there, you are not caught: it doesn't
75 have time to notice you before you leave.) If you were to do this in
76 the configuration above, marking your current position with
77 parentheses, your passage through the firewall would look like this:
78
79 Initial state:
80 0 1 2 3 4 5 6
81 [S] [S] ... ... [S] ... [S]
82 [ ] [ ] [ ] [ ]
83 [ ] [ ] [ ]
84 [ ] [ ]
85
86 Picosecond 0:
87 0 1 2 3 4 5 6
88 (S) [S] ... ... [S] ... [S]
89 [ ] [ ] [ ] [ ]
90 [ ] [ ] [ ]
91 [ ] [ ]
92
93 0 1 2 3 4 5 6
94 ( ) [ ] ... ... [ ] ... [ ]
95 [S] [S] [S] [S]
96 [ ] [ ] [ ]
97 [ ] [ ]
98
99
100 Picosecond 1:
101 0 1 2 3 4 5 6
102 [ ] ( ) ... ... [ ] ... [ ]
103 [S] [S] [S] [S]
104 [ ] [ ] [ ]
105 [ ] [ ]
106
107 0 1 2 3 4 5 6
108 [ ] (S) ... ... [ ] ... [ ]
109 [ ] [ ] [ ] [ ]
110 [S] [S] [S]
111 [ ] [ ]
112
113
114 Picosecond 2:
115 0 1 2 3 4 5 6
116 [ ] [S] (.) ... [ ] ... [ ]
117 [ ] [ ] [ ] [ ]
118 [S] [S] [S]
119 [ ] [ ]
120
121 0 1 2 3 4 5 6
122 [ ] [ ] (.) ... [ ] ... [ ]
123 [S] [S] [ ] [ ]
124 [ ] [ ] [ ]
125 [S] [S]
126
127
128 Picosecond 3:
129 0 1 2 3 4 5 6
130 [ ] [ ] ... (.) [ ] ... [ ]
131 [S] [S] [ ] [ ]
132 [ ] [ ] [ ]
133 [S] [S]
134
135 0 1 2 3 4 5 6
136 [S] [S] ... (.) [ ] ... [ ]
137 [ ] [ ] [ ] [ ]
138 [ ] [S] [S]
139 [ ] [ ]
140
141
142 Picosecond 4:
143 0 1 2 3 4 5 6
144 [S] [S] ... ... ( ) ... [ ]
145 [ ] [ ] [ ] [ ]
146 [ ] [S] [S]
147 [ ] [ ]
148
149 0 1 2 3 4 5 6
150 [ ] [ ] ... ... ( ) ... [ ]
151 [S] [S] [S] [S]
152 [ ] [ ] [ ]
153 [ ] [ ]
154
155
156 Picosecond 5:
157 0 1 2 3 4 5 6
158 [ ] [ ] ... ... [ ] (.) [ ]
159 [S] [S] [S] [S]
160 [ ] [ ] [ ]
161 [ ] [ ]
162
163 0 1 2 3 4 5 6
164 [ ] [S] ... ... [S] (.) [S]
165 [ ] [ ] [ ] [ ]
166 [S] [ ] [ ]
167 [ ] [ ]
168
169
170 Picosecond 6:
171 0 1 2 3 4 5 6
172 [ ] [S] ... ... [S] ... (S)
173 [ ] [ ] [ ] [ ]
174 [S] [ ] [ ]
175 [ ] [ ]
176
177 0 1 2 3 4 5 6
178 [ ] [ ] ... ... [ ] ... ( )
179 [S] [S] [S] [S]
180 [ ] [ ] [ ]
181 [ ] [ ]
182
183 In this situation, you are caught in layers 0 and 6, because your
184 packet entered the layer when its scanner was at the top when you
185 entered it. You are not caught in layer 1, since the scanner moved
186 into the top of the layer once you were already there.
187
188 The severity of getting caught on a layer is equal to its depth
189 multiplied by its range. (Ignore layers in which you do not get
190 caught.) The severity of the whole trip is the sum of these values. In
191 the example above, the trip severity is 0*3 + 6*4 = 24.
192
193 Given the details of the firewall you've recorded, if you leave
194 immediately, what is the severity of your whole trip?
195
196 Your puzzle answer was 1300.
197
198 --- Part Two ---
199
200 Now, you need to pass through the firewall without being caught -
201 easier said than done.
202
203 You can't control the speed of the packet, but you can delay it any
204 number of picoseconds. For each picosecond you delay the packet before
205 beginning your trip, all security scanners move one step. You're not
206 in the firewall during this time; you don't enter layer 0 until you
207 stop delaying the packet.
208
209 In the example above, if you delay 10 picoseconds (picoseconds 0 - 9),
210 you won't get caught:
211
212 State after delaying:
213 0 1 2 3 4 5 6
214 [ ] [S] ... ... [ ] ... [ ]
215 [ ] [ ] [ ] [ ]
216 [S] [S] [S]
217 [ ] [ ]
218
219 Picosecond 10:
220 0 1 2 3 4 5 6
221 ( ) [S] ... ... [ ] ... [ ]
222 [ ] [ ] [ ] [ ]
223 [S] [S] [S]
224 [ ] [ ]
225
226 0 1 2 3 4 5 6
227 ( ) [ ] ... ... [ ] ... [ ]
228 [S] [S] [S] [S]
229 [ ] [ ] [ ]
230 [ ] [ ]
231
232
233 Picosecond 11:
234 0 1 2 3 4 5 6
235 [ ] ( ) ... ... [ ] ... [ ]
236 [S] [S] [S] [S]
237 [ ] [ ] [ ]
238 [ ] [ ]
239
240 0 1 2 3 4 5 6
241 [S] (S) ... ... [S] ... [S]
242 [ ] [ ] [ ] [ ]
243 [ ] [ ] [ ]
244 [ ] [ ]
245
246
247 Picosecond 12:
248 0 1 2 3 4 5 6
249 [S] [S] (.) ... [S] ... [S]
250 [ ] [ ] [ ] [ ]
251 [ ] [ ] [ ]
252 [ ] [ ]
253
254 0 1 2 3 4 5 6
255 [ ] [ ] (.) ... [ ] ... [ ]
256 [S] [S] [S] [S]
257 [ ] [ ] [ ]
258 [ ] [ ]
259
260
261 Picosecond 13:
262 0 1 2 3 4 5 6
263 [ ] [ ] ... (.) [ ] ... [ ]
264 [S] [S] [S] [S]
265 [ ] [ ] [ ]
266 [ ] [ ]
267
268 0 1 2 3 4 5 6
269 [ ] [S] ... (.) [ ] ... [ ]
270 [ ] [ ] [ ] [ ]
271 [S] [S] [S]
272 [ ] [ ]
273
274
275 Picosecond 14:
276 0 1 2 3 4 5 6
277 [ ] [S] ... ... ( ) ... [ ]
278 [ ] [ ] [ ] [ ]
279 [S] [S] [S]
280 [ ] [ ]
281
282 0 1 2 3 4 5 6
283 [ ] [ ] ... ... ( ) ... [ ]
284 [S] [S] [ ] [ ]
285 [ ] [ ] [ ]
286 [S] [S]
287
288
289 Picosecond 15:
290 0 1 2 3 4 5 6
291 [ ] [ ] ... ... [ ] (.) [ ]
292 [S] [S] [ ] [ ]
293 [ ] [ ] [ ]
294 [S] [S]
295
296 0 1 2 3 4 5 6
297 [S] [S] ... ... [ ] (.) [ ]
298 [ ] [ ] [ ] [ ]
299 [ ] [S] [S]
300 [ ] [ ]
301
302
303 Picosecond 16:
304 0 1 2 3 4 5 6
305 [S] [S] ... ... [ ] ... ( )
306 [ ] [ ] [ ] [ ]
307 [ ] [S] [S]
308 [ ] [ ]
309
310 0 1 2 3 4 5 6
311 [ ] [ ] ... ... [ ] ... ( )
312 [S] [S] [S] [S]
313 [ ] [ ] [ ]
314 [ ] [ ]
315
316 Because all smaller delays would get you caught, the fewest number of
317 picoseconds you would need to delay to get through safely is 10.
318
319 What is the fewest number of picoseconds that you need to delay the
320 packet to pass through the firewall without being caught?
321
322 Your puzzle answer was 3870382.
323
324 Both parts of this puzzle are complete! They provide two gold stars: **