File tree Expand file tree Collapse file tree 1 file changed +4
-20
lines changed Expand file tree Collapse file tree 1 file changed +4
-20
lines changed Original file line number Diff line number Diff line change @@ -102,13 +102,13 @@ long long part2(const Data &data)
102
102
103
103
auto left = diskmap.begin ();
104
104
auto right = --diskmap.end ();
105
- while (right->first == -1 ) {
106
- --right;
107
- }
108
105
while (right != diskmap.begin ()) {
109
106
while (left->first != -1 && left != right) {
110
107
++left;
111
108
}
109
+ while (right->first == -1 && left != right) {
110
+ --right;
111
+ }
112
112
if (left == right) {
113
113
left = diskmap.begin ();
114
114
--right;
@@ -137,25 +137,9 @@ long long part2(const Data &data)
137
137
138
138
// the block at the end is now unallocated
139
139
right->first = -1 ;
140
- --right;
141
- while (right->first == -1 || moved.contains (right->first )) {
142
- --right;
143
- if (right == diskmap.begin ()) break ;
144
- }
145
- if (right == diskmap.begin ()) break ;
146
140
}
147
141
else {
148
- ++left;
149
- if (left == right) {
150
- left = diskmap.begin ();
151
- --right;
152
- while (right->first == -1 || moved.contains (right->first )) {
153
- --right;
154
- if (right == diskmap.begin ()) break ;
155
- }
156
- if (right == diskmap.begin ()) break ;
157
- continue ;
158
- }
142
+ ++left;
159
143
}
160
144
// print(diskmap);
161
145
}
You can’t perform that action at this time.
0 commit comments