Day 15
[advent-of-code-2019.git] / day15 / summary.txt
1 --- Day 15: Oxygen System ---
2 Out here in deep space, many things can go wrong. Fortunately, many of those things have indicator lights. Unfortunately, one of those lights is lit: the oxygen system for part of the ship has failed!
3
4 According to the readouts, the oxygen system must have failed days ago after a rupture in oxygen tank two; that section of the ship was automatically sealed once oxygen levels went dangerously low. A single remotely-operated repair droid is your only option for fixing the oxygen system.
5
6 The Elves' care package included an Intcode program (your puzzle input) that you can use to remotely control the repair droid. By running that program, you can direct the repair droid to the oxygen system and fix the problem.
7
8 The remote control program executes the following steps in a loop forever:
9
10 Accept a movement command via an input instruction.
11 Send the movement command to the repair droid.
12 Wait for the repair droid to finish the movement operation.
13 Report on the status of the repair droid via an output instruction.
14 Only four movement commands are understood: north (1), south (2), west (3), and east (4). Any other command is invalid. The movements differ in direction, but not in distance: in a long enough east-west hallway, a series of commands like 4,4,4,4,3,3,3,3 would leave the repair droid back where it started.
15
16 The repair droid can reply with any of the following status codes:
17
18 0: The repair droid hit a wall. Its position has not changed.
19 1: The repair droid has moved one step in the requested direction.
20 2: The repair droid has moved one step in the requested direction; its new position is the location of the oxygen system.
21 You don't know anything about the area around the repair droid, but you can figure it out by watching the status codes.
22
23 For example, we can draw the area using D for the droid, # for walls, . for locations the droid can traverse, and empty space for unexplored locations. Then, the initial state looks like this:
24
25       
26       
27    D  
28       
29       
30 To make the droid go north, send it 1. If it replies with 0, you know that location is a wall and that the droid didn't move:
31
32       
33    #  
34    D  
35       
36       
37 To move east, send 4; a reply of 1 means the movement was successful:
38
39       
40    #  
41    .D 
42       
43       
44 Then, perhaps attempts to move north (1), south (2), and east (4) are all met with replies of 0:
45
46       
47    ## 
48    .D#
49     # 
50       
51 Now, you know the repair droid is in a dead end. Backtrack with 3 (which you already know will get a reply of 1 because you already know that location is open):
52
53       
54    ## 
55    D.#
56     # 
57       
58 Then, perhaps west (3) gets a reply of 0, south (2) gets a reply of 1, south again (2) gets a reply of 0, and then west (3) gets a reply of 2:
59
60       
61    ## 
62   #..#
63   D.# 
64    #  
65 Now, because of the reply of 2, you know you've found the oxygen system! In this example, it was only 2 moves away from the repair droid's starting position.
66
67 What is the fewest number of movement commands required to move the repair droid from its starting position to the location of the oxygen system?
68
69 Your puzzle answer was 238.
70
71 --- Part Two ---
72 You quickly repair the oxygen system; oxygen gradually fills the area.
73
74 Oxygen starts in the location containing the repaired oxygen system. It takes one minute for oxygen to spread to all open locations that are adjacent to a location that already contains oxygen. Diagonal locations are not adjacent.
75
76 In the example above, suppose you've used the droid to explore the area fully and have the following map (where locations that currently contain oxygen are marked O):
77
78  ##   
79 #..## 
80 #.#..#
81 #.O.# 
82  ###  
83 Initially, the only location which contains oxygen is the location of the repaired oxygen system. However, after one minute, the oxygen spreads to all open (.) locations that are adjacent to a location containing oxygen:
84
85  ##   
86 #..## 
87 #.#..#
88 #OOO# 
89  ###  
90 After a total of two minutes, the map looks like this:
91
92  ##   
93 #..## 
94 #O#O.#
95 #OOO# 
96  ###  
97 After a total of three minutes:
98
99  ##   
100 #O.## 
101 #O#OO#
102 #OOO# 
103  ###  
104 And finally, the whole region is full of oxygen after a total of four minutes:
105
106 So, in this example, all locations contain oxygen after 4 minutes.
107
108 Use the repair droid to get a complete map of the area. How many minutes will it take to fill with oxygen?
109
110 Your puzzle answer was 392.
111
112 Both parts of this puzzle are complete! They provide two gold stars: **
113
114 At this point, you should return to your Advent calendar and try another puzzle.
115
116 If you still want to see it, you can get your puzzle input.
117
118 You can also [Share] this puzzle.