Compare commits

..

No commits in common. 'adf256572957c38fba3b359108437aa1b3205bd1' and '4cf318a3608eb3b7a4fb62ead33b859ef9bac86c' have entirely different histories.

  1. 4
      .gitignore
  2. 4
      CMakeLists.txt
  3. 12
      README.md
  4. 10
      src/main.cpp
  5. 3
      src/util.h

4
.gitignore vendored

@ -1,5 +1,3 @@
/cmake-build-debug/ /cmake-build-debug/
session session
/input/ /input/
/xtensor/
/xtl/

@ -8,11 +8,11 @@ if (WIN32)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
endif() endif()
file(GLOB_RECURSE SRC_FILES src/**.cpp) file(GLOB_RECURSE SRC_FILES src/**.cpp src/**.h)
add_executable(AdventOfCode2022 ${SRC_FILES}) add_executable(AdventOfCode2022 ${SRC_FILES})
include(FetchContent) include(FetchContent)
FetchContent_Declare(cpr GIT_REPOSITORY https://github.com/libcpr/cpr.git GIT_TAG 100cf2050be7619430a615cd0d580b33c62fde6b) FetchContent_Declare(cpr GIT_REPOSITORY https://github.com/libcpr/cpr.git GIT_TAG 100cf2050be7619430a615cd0d580b33c62fde6b)
FetchContent_MakeAvailable(cpr) FetchContent_MakeAvailable(cpr)
target_link_libraries(AdventOfCode2022 cpr::cpr) target_link_libraries(AdventOfCode2022 PRIVATE cpr::cpr)

@ -1,12 +0,0 @@
## Advent Of Code 2022 C++ Solutions
#### Build with CMakeLists.txt
#### Run:
Place a file called "session" with your session key cookie from https://adventofcode.com/ inside the Working Directory.
Expects runtime arguments as days, for example:
"5 9 1" executes Days 5, 9, 1 in this order.

@ -3,8 +3,8 @@
#include "days/days.h" #include "days/days.h"
Input getInput(int day, std::string key, bool useTestInput) { std::vector<std::string> getInput(int day, std::string key, bool useTestInput) {
Input input; std::vector<std::string> result;
char dayStrPadded[3]; char dayStrPadded[3];
sprintf(dayStrPadded, "%02u", day); sprintf(dayStrPadded, "%02u", day);
@ -13,7 +13,7 @@ Input getInput(int day, std::string key, bool useTestInput) {
if (!std::filesystem::exists({localFilePath})) { if (!std::filesystem::exists({localFilePath})) {
if (key.empty()) if (key.empty())
return input; return result;
std::string dayStr = std::to_string(day); std::string dayStr = std::to_string(day);
std::string url = "https://adventofcode.com/2021/day/" + dayStr + "/input"; std::string url = "https://adventofcode.com/2021/day/" + dayStr + "/input";
std::cout << "Input does not exist. Fetching from " + url << std::endl; std::cout << "Input does not exist. Fetching from " + url << std::endl;
@ -26,11 +26,11 @@ Input getInput(int day, std::string key, bool useTestInput) {
std::string line; std::string line;
while (std::getline(file, line)) while (std::getline(file, line))
input.push_back(line); result.push_back(line);
file.close(); file.close();
return input; return result;
} }
std::string getSessionKey() { std::string getSessionKey() {

@ -1,7 +1,8 @@
#pragma once #pragma once
#include <vector> #include <vector>
#include <numeric> #include <numeric>
#include <string> #include <string>
#include <tuple> #include <tuple>
#include <iostream> #include <iostream>

Loading…
Cancel
Save