diff --git a/src/Day.h b/src/Day.h index 888365c..3d1e2b2 100644 --- a/src/Day.h +++ b/src/Day.h @@ -4,8 +4,8 @@ #include "util.h" using namespace std::chrono; -typedef std::string Result; -typedef std::vector Input; +typedef string Result; +typedef std::vector Input; class Day { protected: @@ -21,19 +21,19 @@ public: auto start = high_resolution_clock::now(); - std::cout << "Task 1" << std::endl; + cout << "Task 1" << endl; Result result1 = Task1(); auto stop1 = high_resolution_clock::now(); auto dur1 = duration_cast(stop1 - start); - std::cout << "Result: " << result1 << std::endl; - std::cout << "Duration: " << double(dur1.count()) / 1000. << "ms" << std::endl; + cout << "Result: " << result1 << endl; + cout << "Duration: " << double(dur1.count()) / 1000. << "ms" << endl; - std::cout << "Task 2" << std::endl; + cout << "Task 2" << endl; Result result2 = Task2(); auto stop2 = high_resolution_clock::now(); auto dur2 = duration_cast(stop2 - stop1); - std::cout << "Result: " << result2 << std::endl; - std::cout << "Duration: " << double(dur2.count()) / 1000. << "ms" << std::endl << std::endl; + cout << "Result: " << result2 << endl; + cout << "Duration: " << double(dur2.count()) / 1000. << "ms" << endl << endl; return 0; } diff --git a/src/main.cpp b/src/main.cpp index 25dc12a..10e39d1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,20 +3,20 @@ #include "days/days.h" -Input getInput(int day, std::string key, bool useTestInput) { +Input getInput(int day, string key, bool useTestInput) { Input input; char dayStrPadded[3]; sprintf(dayStrPadded, "%02u", day); - std::string postfix = useTestInput ? "_testInput.txt" : "_input.txt"; - std::string localFilePath = "input/" + std::string(dayStrPadded) + postfix; + string postfix = useTestInput ? "_testInput.txt" : "_input.txt"; + string localFilePath = "input/" + string(dayStrPadded) + postfix; if (!std::filesystem::exists({localFilePath})) { if (key.empty()) return input; - std::string dayStr = std::to_string(day); - std::string url = "https://adventofcode.com/2022/day/" + dayStr + "/input"; - std::cout << "Input does not exist. Fetching from " + url << std::endl; + string dayStr = std::to_string(day); + string url = "https://adventofcode.com/2022/day/" + dayStr + "/input"; + cout << "Input does not exist. Fetching from " + url << endl; std::ofstream file(localFilePath); file << cpr::Get(cpr::Url{url}, cpr::Cookies{{"session", key}}).text; file.close(); @@ -24,7 +24,7 @@ Input getInput(int day, std::string key, bool useTestInput) { std::ifstream file(localFilePath); - std::string line; + string line; while (std::getline(file, line)) input.push_back(line); @@ -33,8 +33,8 @@ Input getInput(int day, std::string key, bool useTestInput) { return input; } -std::string getSessionKey() { - std::string key; +string getSessionKey() { + string key; std::ifstream file("session"); if (!file.good()) return ""; @@ -50,14 +50,14 @@ int main(int argc, char *argv[]) { auto days = getAllDays(); std::filesystem::create_directory("input"); - int i = 1; - if (argc > 1 && std::string(argv[1]) == "T") { - useTestInput = true; - i++; - } + int i = 1; + if (argc > 1 && string(argv[1]) == "T") { + useTestInput = true; + i++; + } for (; i < argc; i++) { int dayNum = std::stoi(argv[i]); - std::cout << "Running day " << dayNum << std::endl; + cout << "Running day " << dayNum << endl; Input input = getInput(dayNum, key, useTestInput); Day *day = days[dayNum - 1]; int code = day->run(input);