aboutsummaryrefslogtreecommitdiff
path: root/src/2022/day20/aoc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/2022/day20/aoc.cpp')
-rw-r--r--src/2022/day20/aoc.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/2022/day20/aoc.cpp b/src/2022/day20/aoc.cpp
index 8d1d6ca..28b568f 100644
--- a/src/2022/day20/aoc.cpp
+++ b/src/2022/day20/aoc.cpp
@@ -2,8 +2,18 @@
namespace aoc2022 {
-std::pair<int, int> day20(line_view) {
- return {0, 0};
-}
+std::pair<int, int64_t> day20(line_view file) {
+ message msg{file};
+ msg.relocate();
+ int n = msg.nth(1000)->value + msg.nth(2000)->value + msg.nth(3000)->value;
+
+ message msg1{file};
+ msg1.multiply(811589153);
+ for(auto i = 0; i < 10; i++) {
+ msg1.relocate();
+ }
+ int64_t n1 = msg1.nth(1000)->value + msg1.nth(2000)->value + msg1.nth(3000)->value;
+ return {n, n1};
}
+} // namespace aoc2022