/* * io.cpp * * - This file contains basic funcions to read files and parse them * * - Taken from AfonsoCMSousa (me) advent of code repository: * https://github.com/AfonsoCMSousa/AdventOfCode * * Note: The funtions were changed to better suit the needs of this project, but the original code can be found in the repository above. * Created by AfonsoCMSousa on 21/05/2026. */ #ifndef FILE_IO_CPP #define FILE_IO_CPP #include #include #include #include #include // Reads a file and returns a vector of strings, where each string is a line in the file std::vector> read_char(const char *filePath) { std::ifstream file(filePath); if (!file.is_open()) { throw std::runtime_error("Could not open file"); } std::vector> lines; std::string line; while (std::getline(file, line)) { std::vector charLine(line.begin(), line.end()); lines.push_back(charLine); } file.close(); return lines; } std::vector get_digits(uint64_t number) { std::vector _return_vec; while (number != 0) { _return_vec.push_back(number % 10); number /= 10; } std::reverse(_return_vec.begin(), _return_vec.end()); return _return_vec; } #endif // FILE_IO_CPP