Initial commit

This commit is contained in:
2021-12-01 20:31:53 +00:00
commit 2f44ccc3a7
106 changed files with 9333 additions and 0 deletions

31
2015/puzzle-12-01.cc Normal file
View File

@@ -0,0 +1,31 @@
#include <cassert>
#include <functional>
#include <iostream>
#include <map>
#include <regex>
#include <set>
#include <string>
#include <variant>
int parse_numbers(std::string const &s) {
static const std::regex re("-?\\d+");
std::string left = s;
std::smatch m;
int acc = 0;
while (std::regex_search(left, m, re)) {
acc += std::stoi(m.str(0));
left = m.suffix();
}
return acc;
}
int main(int argc, char **argv) {
int acc = 0;
for (std::string line; std::getline(std::cin, line);) {
acc += parse_numbers(line);
}
std::cout << "Accumulated value: " << acc << "\n";
return 0;
}