aboutsummaryrefslogtreecommitdiff
path: root/src/2022/day5/aoc.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/2022/day5/aoc.h')
-rw-r--r--src/2022/day5/aoc.h14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/2022/day5/aoc.h b/src/2022/day5/aoc.h
index be1791e..1014bb7 100644
--- a/src/2022/day5/aoc.h
+++ b/src/2022/day5/aoc.h
@@ -1,5 +1,5 @@
#include "common.h"
-#include <vector>
+#include <stack>
namespace aoc2022 {
@@ -103,13 +103,13 @@ struct crate {
}
}
if (mode == 2) {
- std::vector<crate*> dx;
- for (int x = 0; x < d[0]; x++) {
- crate* c = take(d[1]);
- dx.push_back(c);
+ std::stack<crate*> dx;
+ while(d[0]-- > 0) {
+ dx.push(take(d[1]));
}
- for (auto s = dx.size(); s > 0; s--) {
- put(dx[s - 1], d[2]);
+ while(!dx.empty()) {
+ put(dx.top(), d[2]);
+ dx.pop();
}
}
}