Setup AoC for 2025
This commit is contained in:
@@ -14,8 +14,16 @@ for item in $list; do
|
||||
if [ ! -e $dir ]; then
|
||||
webitem=$(echo $day | sed 's/^0//g')
|
||||
echo "Fetching $dir"
|
||||
mkdir -p "res/$year/day$day/"
|
||||
touch "res/$year/day$day/test_input.txt"
|
||||
curl -s --cookie cookies.txt https://adventofcode.com/$year/day/$webitem/input >$dir
|
||||
tmp_file=$(mktemp)
|
||||
HTTP_CODE=$(curl -s -w "%{http_code}" -o "$tmp_file" --cookie cookies.txt https://adventofcode.com/$year/day/$webitem/input)
|
||||
if [ "$HTTP_CODE" -eq 200 ]; then
|
||||
mkdir -p "res/$year/day$day/"
|
||||
touch "res/$year/day$day/test_input.txt"
|
||||
mv "$tmp_file" $dir
|
||||
else
|
||||
echo "Failed to fetch with status: $HTTP_CODE"
|
||||
rm "$tmp_file"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
#include "common/aoc.h"
|
||||
|
||||
namespace y2025::day01
|
||||
{
|
||||
using InputType = std::vector<int>;
|
||||
REGISTER_DAY(2025, Day01, InputType, int);
|
||||
|
||||
REGISTER_TEST_EXAMPLE(2025, Day01, ExampleInput, 1, 0);
|
||||
REGISTER_TEST(2025, Day01, Input, 1, 0);
|
||||
REGISTER_TEST_EXAMPLE(2025, Day01, ExampleInput, 2, 0);
|
||||
REGISTER_TEST(2025, Day01, Input, 2, 0);
|
||||
|
||||
READ_INPUT(input)
|
||||
{
|
||||
std::vector<int> vec;
|
||||
std::string str;
|
||||
while (std::getline(input, str))
|
||||
{
|
||||
std::stringstream ss{str};
|
||||
int n;
|
||||
ss >> n;
|
||||
vec.emplace_back(n);
|
||||
}
|
||||
return vec;
|
||||
}
|
||||
|
||||
OUTPUT1(input)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
OUTPUT2(input)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#include "common/aoc.h"
|
||||
|
||||
namespace y2025::day02
|
||||
{
|
||||
using InputType = std::vector<int>;
|
||||
REGISTER_DAY(2025, Day02, InputType, int);
|
||||
|
||||
REGISTER_TEST_EXAMPLE(2025, Day02, ExampleInput, 1, 0);
|
||||
REGISTER_TEST(2025, Day02, Input, 1, 0);
|
||||
REGISTER_TEST_EXAMPLE(2025, Day02, ExampleInput, 2, 0);
|
||||
REGISTER_TEST(2025, Day02, Input, 2, 0);
|
||||
|
||||
READ_INPUT(input)
|
||||
{
|
||||
std::vector<int> vec;
|
||||
std::string str;
|
||||
while (std::getline(input, str))
|
||||
{
|
||||
std::stringstream ss{str};
|
||||
int n;
|
||||
ss >> n;
|
||||
vec.emplace_back(n);
|
||||
}
|
||||
return vec;
|
||||
}
|
||||
|
||||
OUTPUT1(input)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
OUTPUT2(input)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#include "common/aoc.h"
|
||||
|
||||
namespace y2025::day03
|
||||
{
|
||||
using InputType = std::vector<int>;
|
||||
REGISTER_DAY(2025, Day03, InputType, int);
|
||||
|
||||
REGISTER_TEST_EXAMPLE(2025, Day03, ExampleInput, 1, 0);
|
||||
REGISTER_TEST(2025, Day03, Input, 1, 0);
|
||||
REGISTER_TEST_EXAMPLE(2025, Day03, ExampleInput, 2, 0);
|
||||
REGISTER_TEST(2025, Day03, Input, 2, 0);
|
||||
|
||||
READ_INPUT(input)
|
||||
{
|
||||
std::vector<int> vec;
|
||||
std::string str;
|
||||
while (std::getline(input, str))
|
||||
{
|
||||
std::stringstream ss{str};
|
||||
int n;
|
||||
ss >> n;
|
||||
vec.emplace_back(n);
|
||||
}
|
||||
return vec;
|
||||
}
|
||||
|
||||
OUTPUT1(input)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
OUTPUT2(input)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#include "common/aoc.h"
|
||||
|
||||
namespace y2025::day04
|
||||
{
|
||||
using InputType = std::vector<int>;
|
||||
REGISTER_DAY(2025, Day04, InputType, int);
|
||||
|
||||
REGISTER_TEST_EXAMPLE(2025, Day04, ExampleInput, 1, 0);
|
||||
REGISTER_TEST(2025, Day04, Input, 1, 0);
|
||||
REGISTER_TEST_EXAMPLE(2025, Day04, ExampleInput, 2, 0);
|
||||
REGISTER_TEST(2025, Day04, Input, 2, 0);
|
||||
|
||||
READ_INPUT(input)
|
||||
{
|
||||
std::vector<int> vec;
|
||||
std::string str;
|
||||
while (std::getline(input, str))
|
||||
{
|
||||
std::stringstream ss{str};
|
||||
int n;
|
||||
ss >> n;
|
||||
vec.emplace_back(n);
|
||||
}
|
||||
return vec;
|
||||
}
|
||||
|
||||
OUTPUT1(input)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
OUTPUT2(input)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#include "common/aoc.h"
|
||||
|
||||
namespace y2025::day05
|
||||
{
|
||||
using InputType = std::vector<int>;
|
||||
REGISTER_DAY(2025, Day05, InputType, int);
|
||||
|
||||
REGISTER_TEST_EXAMPLE(2025, Day05, ExampleInput, 1, 0);
|
||||
REGISTER_TEST(2025, Day05, Input, 1, 0);
|
||||
REGISTER_TEST_EXAMPLE(2025, Day05, ExampleInput, 2, 0);
|
||||
REGISTER_TEST(2025, Day05, Input, 2, 0);
|
||||
|
||||
READ_INPUT(input)
|
||||
{
|
||||
std::vector<int> vec;
|
||||
std::string str;
|
||||
while (std::getline(input, str))
|
||||
{
|
||||
std::stringstream ss{str};
|
||||
int n;
|
||||
ss >> n;
|
||||
vec.emplace_back(n);
|
||||
}
|
||||
return vec;
|
||||
}
|
||||
|
||||
OUTPUT1(input)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
OUTPUT2(input)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#include "common/aoc.h"
|
||||
|
||||
namespace y2025::day06
|
||||
{
|
||||
using InputType = std::vector<int>;
|
||||
REGISTER_DAY(2025, Day06, InputType, int);
|
||||
|
||||
REGISTER_TEST_EXAMPLE(2025, Day06, ExampleInput, 1, 0);
|
||||
REGISTER_TEST(2025, Day06, Input, 1, 0);
|
||||
REGISTER_TEST_EXAMPLE(2025, Day06, ExampleInput, 2, 0);
|
||||
REGISTER_TEST(2025, Day06, Input, 2, 0);
|
||||
|
||||
READ_INPUT(input)
|
||||
{
|
||||
std::vector<int> vec;
|
||||
std::string str;
|
||||
while (std::getline(input, str))
|
||||
{
|
||||
std::stringstream ss{str};
|
||||
int n;
|
||||
ss >> n;
|
||||
vec.emplace_back(n);
|
||||
}
|
||||
return vec;
|
||||
}
|
||||
|
||||
OUTPUT1(input)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
OUTPUT2(input)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#include "common/aoc.h"
|
||||
|
||||
namespace y2025::day07
|
||||
{
|
||||
using InputType = std::vector<int>;
|
||||
REGISTER_DAY(2025, Day07, InputType, int);
|
||||
|
||||
REGISTER_TEST_EXAMPLE(2025, Day07, ExampleInput, 1, 0);
|
||||
REGISTER_TEST(2025, Day07, Input, 1, 0);
|
||||
REGISTER_TEST_EXAMPLE(2025, Day07, ExampleInput, 2, 0);
|
||||
REGISTER_TEST(2025, Day07, Input, 2, 0);
|
||||
|
||||
READ_INPUT(input)
|
||||
{
|
||||
std::vector<int> vec;
|
||||
std::string str;
|
||||
while (std::getline(input, str))
|
||||
{
|
||||
std::stringstream ss{str};
|
||||
int n;
|
||||
ss >> n;
|
||||
vec.emplace_back(n);
|
||||
}
|
||||
return vec;
|
||||
}
|
||||
|
||||
OUTPUT1(input)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
OUTPUT2(input)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#include "common/aoc.h"
|
||||
|
||||
namespace y2025::day08
|
||||
{
|
||||
using InputType = std::vector<int>;
|
||||
REGISTER_DAY(2025, Day08, InputType, int);
|
||||
|
||||
REGISTER_TEST_EXAMPLE(2025, Day08, ExampleInput, 1, 0);
|
||||
REGISTER_TEST(2025, Day08, Input, 1, 0);
|
||||
REGISTER_TEST_EXAMPLE(2025, Day08, ExampleInput, 2, 0);
|
||||
REGISTER_TEST(2025, Day08, Input, 2, 0);
|
||||
|
||||
READ_INPUT(input)
|
||||
{
|
||||
std::vector<int> vec;
|
||||
std::string str;
|
||||
while (std::getline(input, str))
|
||||
{
|
||||
std::stringstream ss{str};
|
||||
int n;
|
||||
ss >> n;
|
||||
vec.emplace_back(n);
|
||||
}
|
||||
return vec;
|
||||
}
|
||||
|
||||
OUTPUT1(input)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
OUTPUT2(input)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#include "common/aoc.h"
|
||||
|
||||
namespace y2025::day09
|
||||
{
|
||||
using InputType = std::vector<int>;
|
||||
REGISTER_DAY(2025, Day09, InputType, int);
|
||||
|
||||
REGISTER_TEST_EXAMPLE(2025, Day09, ExampleInput, 1, 0);
|
||||
REGISTER_TEST(2025, Day09, Input, 1, 0);
|
||||
REGISTER_TEST_EXAMPLE(2025, Day09, ExampleInput, 2, 0);
|
||||
REGISTER_TEST(2025, Day09, Input, 2, 0);
|
||||
|
||||
READ_INPUT(input)
|
||||
{
|
||||
std::vector<int> vec;
|
||||
std::string str;
|
||||
while (std::getline(input, str))
|
||||
{
|
||||
std::stringstream ss{str};
|
||||
int n;
|
||||
ss >> n;
|
||||
vec.emplace_back(n);
|
||||
}
|
||||
return vec;
|
||||
}
|
||||
|
||||
OUTPUT1(input)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
OUTPUT2(input)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#include "common/aoc.h"
|
||||
|
||||
namespace y2025::day10
|
||||
{
|
||||
using InputType = std::vector<int>;
|
||||
REGISTER_DAY(2025, Day10, InputType, int);
|
||||
|
||||
REGISTER_TEST_EXAMPLE(2025, Day10, ExampleInput, 1, 0);
|
||||
REGISTER_TEST(2025, Day10, Input, 1, 0);
|
||||
REGISTER_TEST_EXAMPLE(2025, Day10, ExampleInput, 2, 0);
|
||||
REGISTER_TEST(2025, Day10, Input, 2, 0);
|
||||
|
||||
READ_INPUT(input)
|
||||
{
|
||||
std::vector<int> vec;
|
||||
std::string str;
|
||||
while (std::getline(input, str))
|
||||
{
|
||||
std::stringstream ss{str};
|
||||
int n;
|
||||
ss >> n;
|
||||
vec.emplace_back(n);
|
||||
}
|
||||
return vec;
|
||||
}
|
||||
|
||||
OUTPUT1(input)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
OUTPUT2(input)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#include "common/aoc.h"
|
||||
|
||||
namespace y2025::day11
|
||||
{
|
||||
using InputType = std::vector<int>;
|
||||
REGISTER_DAY(2025, Day11, InputType, int);
|
||||
|
||||
REGISTER_TEST_EXAMPLE(2025, Day11, ExampleInput, 1, 0);
|
||||
REGISTER_TEST(2025, Day11, Input, 1, 0);
|
||||
REGISTER_TEST_EXAMPLE(2025, Day11, ExampleInput, 2, 0);
|
||||
REGISTER_TEST(2025, Day11, Input, 2, 0);
|
||||
|
||||
READ_INPUT(input)
|
||||
{
|
||||
std::vector<int> vec;
|
||||
std::string str;
|
||||
while (std::getline(input, str))
|
||||
{
|
||||
std::stringstream ss{str};
|
||||
int n;
|
||||
ss >> n;
|
||||
vec.emplace_back(n);
|
||||
}
|
||||
return vec;
|
||||
}
|
||||
|
||||
OUTPUT1(input)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
OUTPUT2(input)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#include "common/aoc.h"
|
||||
|
||||
namespace y2025::day12
|
||||
{
|
||||
using InputType = std::vector<int>;
|
||||
REGISTER_DAY(2025, Day12, InputType, int);
|
||||
|
||||
REGISTER_TEST_EXAMPLE(2025, Day12, ExampleInput, 1, 0);
|
||||
REGISTER_TEST(2025, Day12, Input, 1, 0);
|
||||
REGISTER_TEST_EXAMPLE(2025, Day12, ExampleInput, 2, 0);
|
||||
REGISTER_TEST(2025, Day12, Input, 2, 0);
|
||||
|
||||
READ_INPUT(input)
|
||||
{
|
||||
std::vector<int> vec;
|
||||
std::string str;
|
||||
while (std::getline(input, str))
|
||||
{
|
||||
std::stringstream ss{str};
|
||||
int n;
|
||||
ss >> n;
|
||||
vec.emplace_back(n);
|
||||
}
|
||||
return vec;
|
||||
}
|
||||
|
||||
OUTPUT1(input)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
OUTPUT2(input)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
+64
-5
@@ -10,17 +10,72 @@ aoc::Registry* aoc::Registry::GetInstance()
|
||||
return instance;
|
||||
}
|
||||
|
||||
struct Args
|
||||
{
|
||||
std::string testRegex{""};
|
||||
bool stopIfFailed{false};
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& os, const Args& args)
|
||||
{
|
||||
return os << "regex=" << args.testRegex << "\nstopIfFailed=" << (args.stopIfFailed ? "true" : "false");
|
||||
}
|
||||
};
|
||||
|
||||
Args ParseArgs(const std::vector<std::string>& arguments)
|
||||
{
|
||||
Args args;
|
||||
for (const std::string& argument : arguments)
|
||||
{
|
||||
if (Helper::StartsWith(argument, "--stop-if-failed"))
|
||||
{
|
||||
args.stopIfFailed = true;
|
||||
}
|
||||
else if (Helper::StartsWith(argument, "--filter="))
|
||||
{
|
||||
args.testRegex = std::string(argument).substr(sizeof("--filter=") - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Unknown argument: " << argument << std::endl;
|
||||
}
|
||||
}
|
||||
return args;
|
||||
}
|
||||
|
||||
std::vector<std::string> ReadArgs(int argc, char** argv)
|
||||
{
|
||||
std::vector<std::string> arguments;
|
||||
for (int i = 1; i < argc; i++)
|
||||
{
|
||||
arguments.emplace_back(argv[i]);
|
||||
}
|
||||
|
||||
if (arguments.empty())
|
||||
{
|
||||
std::ifstream inputStream{"config.txt"};
|
||||
if (inputStream.is_open())
|
||||
{
|
||||
std::string str;
|
||||
while (inputStream >> str)
|
||||
{
|
||||
arguments.emplace_back(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
return arguments;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
std::regex regex{""};
|
||||
if (argc > 1)
|
||||
regex = argv[1];
|
||||
Args args = ParseArgs(ReadArgs(argc, argv));
|
||||
std::regex regex{args.testRegex};
|
||||
Timer totalTimer;
|
||||
int passed = 0;
|
||||
int skipped = 0;
|
||||
for (auto day : aoc::Registry::GetDays())
|
||||
bool stopped = false;
|
||||
for (const auto& day : aoc::Registry::GetDays())
|
||||
{
|
||||
if (!std::regex_search(day->GetName(), regex))
|
||||
if (!std::regex_search(day->GetName(), regex) || stopped)
|
||||
{
|
||||
skipped++;
|
||||
continue;
|
||||
@@ -42,6 +97,10 @@ int main(int argc, char** argv)
|
||||
{
|
||||
std::cout << TERM_RED << "[=========] " << TERM_CLEAR << std::endl;
|
||||
std::cout << TERM_RED << "[ FAILED ] " << TERM_CLEAR << day->GetName() << std::endl;
|
||||
if (args.stopIfFailed)
|
||||
{
|
||||
stopped = true;
|
||||
}
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user