horvathm

Day 18 part 2, using C++ compiler

Dec 18th, 2020 (edited)
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 25.40 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. struct N {
  5.     int64_t v;
  6. };
  7.  
  8. N operator "" _(unsigned long long v) { return { int64_t(v) }; }
  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]+)/\1_/g ; s/\*/-/g ; s/\+/\//g ; s/$/,/' input
Add Comment
Please, Sign In to add comment