aboutsummaryrefslogtreecommitdiff
path: root/src/2021/day2/aoc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/2021/day2/aoc.cpp')
-rw-r--r--src/2021/day2/aoc.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/2021/day2/aoc.cpp b/src/2021/day2/aoc.cpp
index 7a3c895..fa415ef 100644
--- a/src/2021/day2/aoc.cpp
+++ b/src/2021/day2/aoc.cpp
@@ -2,4 +2,16 @@
namespace aoc2021 {
+std::pair<int, int> day2(line_view file) {
+ meters m1{0, 0};
+ meters m2{0, 0};
+ int aim;
+ per_line(file, [&m1, &m2, &aim](line_view lv) {
+ m1.apply(lv);
+ m2.apply(lv, &aim);
+ return true;
+ });
+ return {m1.depth * m1.horizontal, m2.depth * m2.horizontal};
}
+
+} // namespace aoc2021