1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
--- Day 22: Reactor Reboot ---
Operating at these extreme ocean depths has overloaded the submarine's reactor; it needs to be
rebooted.
The reactor core is made up of a large 3-dimensional grid made up entirely of cubes, one cube per
integer 3-dimensional coordinate (x,y,z). Each cube can be either [1m[97mon[0m or [1m[97moff[0m; at the start of the
reboot process, they are all [1m[97moff[0m. (Could it be an old model of a reactor you've seen before?)
To reboot the reactor, you just need to set all of the cubes to either [1m[97mon[0m or [1m[97moff[0m by following a list
of [1m[97mreboot steps[0m (your puzzle input). Each step specifies a cuboid (the set of all cubes that have
coordinates which fall within ranges for x, y, and z) and whether to turn all of the cubes in that
cuboid [1m[97mon[0m or [1m[97moff[0m.
For example, given these reboot steps:
on x=10..12,y=10..12,z=10..12
on x=11..13,y=11..13,z=11..13
off x=9..11,y=9..11,z=9..11
on x=10..10,y=10..10,z=10..10
The first step (on x=10..12,y=10..12,z=10..12) turns [1m[97mon[0m a 3x3x3 cuboid consisting of 27 cubes:
- 10,10,10
- 10,10,11
- 10,10,12
- 10,11,10
- 10,11,11
- 10,11,12
- 10,12,10
- 10,12,11
- 10,12,12
- 11,10,10
- 11,10,11
- 11,10,12
- 11,11,10
- 11,11,11
- 11,11,12
- 11,12,10
- 11,12,11
- 11,12,12
- 12,10,10
- 12,10,11
- 12,10,12
- 12,11,10
- 12,11,11
- 12,11,12
- 12,12,10
- 12,12,11
- 12,12,12
The second step (on x=11..13,y=11..13,z=11..13) turns [1m[97mon[0m a 3x3x3 cuboid that overlaps with the
first. As a result, only 19 additional cubes turn on; the rest are already on from the previous
step:
- 11,11,13
- 11,12,13
- 11,13,11
- 11,13,12
- 11,13,13
- 12,11,13
- 12,12,13
- 12,13,11
- 12,13,12
- 12,13,13
- 13,11,11
- 13,11,12
- 13,11,13
- 13,12,11
- 13,12,12
- 13,12,13
- 13,13,11
- 13,13,12
- 13,13,13
The third step (off x=9..11,y=9..11,z=9..11) turns [1m[97moff[0m a 3x3x3 cuboid that overlaps partially with
some cubes that are on, ultimately turning off 8 cubes:
- 10,10,10
- 10,10,11
- 10,11,10
- 10,11,11
- 11,10,10
- 11,10,11
- 11,11,10
- 11,11,11
The final step (on x=10..10,y=10..10,z=10..10) turns [1m[97mon[0m a single cube, 10,10,10. After this last
step, [1m[97m39[0m cubes are [1m[97mon[0m.
The initialization procedure only uses cubes that have x, y, and z positions of at least -50 and at
most 50. For now, ignore cubes outside this region.
Here is a larger example:
on x=-20..26,y=-36..17,z=-47..7
on x=-20..33,y=-21..23,z=-26..28
on x=-22..28,y=-29..23,z=-38..16
on x=-46..7,y=-6..46,z=-50..-1
on x=-49..1,y=-3..46,z=-24..28
on x=2..47,y=-22..22,z=-23..27
on x=-27..23,y=-28..26,z=-21..29
on x=-39..5,y=-6..47,z=-3..44
on x=-30..21,y=-8..43,z=-13..34
on x=-22..26,y=-27..20,z=-29..19
off x=-48..-32,y=26..41,z=-47..-37
on x=-12..35,y=6..50,z=-50..-2
off x=-48..-32,y=-32..-16,z=-15..-5
on x=-18..26,y=-33..15,z=-7..46
off x=-40..-22,y=-38..-28,z=23..41
on x=-16..35,y=-41..10,z=-47..6
off x=-32..-23,y=11..30,z=-14..3
on x=-49..-5,y=-3..45,z=-29..18
off x=18..30,y=-20..-8,z=-3..13
on x=-41..9,y=-7..43,z=-33..15
on x=-54112..-39298,y=-85059..-49293,z=-27449..7877
on x=967..23432,y=45373..81175,z=27513..53682
The last two steps are fully outside the initialization procedure area; all other steps are fully
within it. After executing these steps in the initialization procedure region, [1m[97m590784[0m cubes are
[1m[97mon[0m.
Execute the reboot steps. Afterward, considering only cubes in the region
x=-50..50,y=-50..50,z=-50..50, [1m[97mhow many cubes are on?[0m
|