Skip to content

Commit 5910223

Browse files
committed
Implement day 15 part 2
1 parent c9601e7 commit 5910223

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

day15/src/day15.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ struct Board {
125125
Vec2<int> dir = inst_dir(inst);
126126
Vec2<int> next = robot + dir;
127127

128+
if (is_wall(next)) {
129+
return;
130+
}
131+
128132
std::unordered_set<Vec2<int>> attached;
129133
dfs_attached(next, inst, attached);
130134

@@ -246,15 +250,9 @@ int main(int argc, char *argv[]) {
246250
state = State::parse_from(file);
247251
}
248252

249-
std::cout << state.board1;
250-
std::cout << state.board2;
251-
for (Inst inst : state.insts) {
252-
state.board2.perform(inst);
253-
std::cout << "After " << inst << ": " << std::endl << state.board2;
254-
}
255-
// state.run();
256-
// std::cout << "Part 1: " << state.board1.sum_box_coords() << std::endl;
257-
// std::cout << "Part 2: " << state.board2.sum_box_coords() << std::endl;
253+
state.run();
254+
std::cout << "Part 1: " << state.board1.sum_box_coords() << std::endl;
255+
std::cout << "Part 2: " << state.board2.sum_box_coords() << std::endl;
258256

259257
return 0;
260258
}

0 commit comments

Comments
 (0)