|
1 | 1 | #include "common_headers.hpp" |
2 | 2 | #include "Cursor.hpp" |
3 | 3 |
|
4 | | -#include <vector> |
| 4 | +#include <tuple> |
5 | 5 | #include <set> |
6 | 6 | #include <unordered_set> |
7 | 7 |
|
@@ -150,80 +150,6 @@ template<typename TGraph> |
150 | 150 | std::cout << "\nmoves " << moves; |
151 | 151 | return unique.size(); |
152 | 152 | } |
153 | | -#if 0 |
154 | | -template<typename TGraph> |
155 | | -[[nodiscard]] size_t solveSecondPart2(TGraph& graph) |
156 | | -{ |
157 | | - std::vector<std::set<int>> colObst(graph.size()); |
158 | | - std::vector<std::set<int>> rowObst(graph[0].size()); |
159 | | - |
160 | | - for(int r = 0; r < graph.size(); ++r) { |
161 | | - for(int c = 0; c < graph[0].size(); ++c) { |
162 | | - if(graph[r][c] == '#') { |
163 | | - colObst[c].emplace(r); |
164 | | - rowObst[r].emplace(c); |
165 | | - } |
166 | | - } |
167 | | - } |
168 | | - |
169 | | - constexpr std::array<char, 4> figures{'|', '-', '|', '-'}; |
170 | | - auto [direction, row, col] = findInitialPosition(graph); |
171 | | - graph[row][col] = '.'; |
172 | | - Cursor cursor{direction, row, col}; |
173 | | - size_t moves{}; |
174 | | - while(cursor.x() < graph.size() && cursor.y() < graph[0].size() && cursor.x() >= 0 && cursor.y() >= 0) { |
175 | | - const auto curChar{graph[cursor.x()][cursor.y()]}; |
176 | | - |
177 | | - if(curChar == '#') { |
178 | | - cursor.stepBack(); |
179 | | - cursor.turnRight(); |
180 | | - } |
181 | | - else { |
182 | | - |
183 | | - if(curChar != '.') { |
184 | | - switch (cursor.direction()) |
185 | | - { |
186 | | - case Cursor::Direction::Right: |
187 | | - if(curChar & Dirs::Down) { |
188 | | - ++moves; |
189 | | - unique.emplace(cursor.x(), cursor.y(), cursor.direction()); |
190 | | - std::cerr << "\nhit right: " << cursor.x() << " " << cursor.y(); |
191 | | - } |
192 | | - break; |
193 | | - case Cursor::Direction::Up: |
194 | | - if(curChar & Dirs::Right) { |
195 | | - ++moves; |
196 | | - unique.emplace(cursor.x(), cursor.y(), cursor.direction()); |
197 | | - |
198 | | - std::cerr << "\nhit up: " << cursor.x() << " " << cursor.y(); |
199 | | - } |
200 | | - break; |
201 | | - case Cursor::Direction::Down: |
202 | | - if(curChar & Dirs::Left) { |
203 | | - ++moves; |
204 | | - unique.emplace(cursor.x(), cursor.y(), cursor.direction()); |
205 | | - |
206 | | - std::cerr << "\nhit down: " << cursor.x() << " " << cursor.y(); |
207 | | - } |
208 | | - break; |
209 | | - case Cursor::Direction::Left: |
210 | | - if(curChar & Dirs::Up) { |
211 | | - ++moves; |
212 | | - unique.emplace(cursor.x(), cursor.y(), cursor.direction()); |
213 | | - |
214 | | - std::cerr << "\nhit left: " << cursor.x() << " " << cursor.y(); |
215 | | - } |
216 | | - break; |
217 | | - } |
218 | | - } |
219 | | - |
220 | | - cursor.move(); |
221 | | - } |
222 | | - } |
223 | | - std::cout << "\nmoves " << moves; |
224 | | - return unique.size(); |
225 | | -} |
226 | | -#endif |
227 | 153 |
|
228 | 154 | void printHelp() |
229 | 155 | { |
|
0 commit comments