horvathm

Day 18 part 1, using C++ compiler

Dec 18th, 2020 (edited)
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 34.52 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. struct N {
  5.     N(int64_t v) : v(v) {}
  6.     int64_t v;
  7. };
  8.  
  9. N operator+(N a, N b) { return { a.v + b.v }; }
  10. N operator-(N a, N b) { return { a.v * b.v }; }
  11.  
  12. extern std::vector<N> values;
  13.  
  14. int main() {
  15.     int64_t sum = 0;
  16.     for (auto& value : values) {
  17.         sum += value.v;
  18.     }
  19.     std::cout << sum << std::endl;
  20. }
  21.  
  22. // Process your input like this:
  23. // sed -E 's/[0-9]+/N(\0)/g ; s/\*/-/g ; s/$/,/' input
Add Comment
Please, Sign In to add comment