aboutsummaryrefslogtreecommitdiff
path: root/src/2022/day23/aoc.cpp
diff options
context:
space:
mode:
authorkaiwu <kaiwu2004@gmail.com>2023-01-04 23:17:39 +0800
committerkaiwu <kaiwu2004@gmail.com>2023-01-04 23:17:39 +0800
commitbc1cd8a9693e81e5cae299ed0670e60ee65f8264 (patch)
tree7a6dcd1985e5593f439c0e34d67cb7ff06cda088 /src/2022/day23/aoc.cpp
parent0d3caf977163d2901cce2c6613d25a80ea840e50 (diff)
downloadadvent-of-code-bc1cd8a9693e81e5cae299ed0670e60ee65f8264.tar.gz
advent-of-code-bc1cd8a9693e81e5cae299ed0670e60ee65f8264.zip
2022 day23 part1 check duplicate
Diffstat (limited to 'src/2022/day23/aoc.cpp')
-rw-r--r--src/2022/day23/aoc.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/2022/day23/aoc.cpp b/src/2022/day23/aoc.cpp
index 1b5a9e6..1d60f78 100644
--- a/src/2022/day23/aoc.cpp
+++ b/src/2022/day23/aoc.cpp
@@ -86,6 +86,10 @@ static struct elf_test {
elf_move m;
} moves[5] = {{eight, nomove}, {north_three, north}, {south_three, south}, {west_three, west}, {east_three, east}};
+bool duplicate(elf e, const std::vector<elf>& elfs) {
+ return false;
+}
+
std::vector<elf> round(int i, const std::vector<elf>& elfs, const std::set<elf>& elves) {
std::vector<elf> next;
for (auto& e : elfs) {
@@ -103,6 +107,11 @@ std::vector<elf> round(int i, const std::vector<elf>& elfs, const std::set<elf>&
}
// check duplicate of next
+ for(size_t i = 0; i < next.size(); i++) {
+ if (duplicate(next[i], next)) {
+ next[i] = elfs[i]; // stay put
+ }
+ }
return next;
}