Compare commits

...

5 Commits

  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,3 +1,5 @@
/cmake-build-debug/
session
/input/
/input/
/xtensor/
/xtl/

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

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

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