#include #include template int search(Iter from, Iter to) { while(from < to) { char c = *(from++); if (std::isdigit(c)) { return c - '0'; } } return 0; } int main(void) { int answer{}; std::ifstream input{ "./resources/input.txt" }; if (input) { std::string line; while(not std::getline(input, line).eof()) { answer += 10 * search(line.begin(), line.end()); answer += search(line.rbegin(), line.rend()); } } input.close(); std::cout << answer << std::endl; return 0; }