diff options
| author | Orfeas <38209077+0xfea5@users.noreply.github.com> | 2025-08-27 04:16:05 +0300 |
|---|---|---|
| committer | Orfeas <38209077+0xfea5@users.noreply.github.com> | 2025-09-01 04:51:37 +0300 |
| commit | d5c2821d589ef36f885bb4f92a6d6ca0bc4cc0e7 (patch) | |
| tree | 268b9c82a4f26dc009eb852fb5419cc44ab81f01 | |
| parent | .gitignore: ignore binaries, lsp cache and compile_commands.json (diff) | |
| download | aoc24-d5c2821d589ef36f885bb4f92a6d6ca0bc4cc0e7.tar.gz aoc24-d5c2821d589ef36f885bb4f92a6d6ca0bc4cc0e7.zip | |
Add ‘skel/‘ as template directory for each day
| -rw-r--r-- | aoc.mk | 32 | ||||
| -rwxr-xr-x | init.sh | 4 | ||||
| -rw-r--r-- | skel/Makefile | 1 | ||||
| -rw-r--r-- | skel/solution.cpp | 27 | ||||
| -rw-r--r-- | skel/tests/test1.input | 0 | ||||
| -rw-r--r-- | skel/tests/test1.output | 0 |
6 files changed, 61 insertions, 3 deletions
| @@ -0,0 +1,32 @@ | |||
| 1 | CXX = g++ | ||
| 2 | CXX_FLAGS = -std=c++23 | ||
| 3 | SOLUTION = solution.cpp | ||
| 4 | INPUT = input.txt | ||
| 5 | TARGET = ./solution | ||
| 6 | TESTS = $(wildcard tests/*.input) | ||
| 7 | TIMEOUT = 5 | ||
| 8 | |||
| 9 | .PHONY: run tests force | ||
| 10 | |||
| 11 | all: compile run | ||
| 12 | |||
| 13 | compile: ${TARGET} | ||
| 14 | |||
| 15 | ${TARGET}: ${SOLUTION} | ||
| 16 | ${CXX} ${CXX_FLAGS} $? -o $@ | ||
| 17 | |||
| 18 | force: | ||
| 19 | |||
| 20 | tests: ${TESTS} | ||
| 21 | |||
| 22 | tests/test%.input: tests/test%.output compile force | ||
| 23 | @diff <(timeout ${TIMEOUT} ${TARGET} < $@) <(cat $<) > /tmp/aoc.output \ | ||
| 24 | && echo -e "$@ [\e[0;32mok\e[m]" \ | ||
| 25 | || echo -e "$@ [\e[0;31mfail\e[m]" | ||
| 26 | @cat /tmp/aoc.output | ||
| 27 | |||
| 28 | run: compile | ||
| 29 | timeout ${TIMEOUT} ${TARGET} < ${INPUT} | ||
| 30 | |||
| 31 | clean: | ||
| 32 | rm -f ${TARGET} | ||
| @@ -13,11 +13,9 @@ cookiefile=${3:-'./cookie'} | |||
| 13 | dir=$(printf "day%02d" $day) | 13 | dir=$(printf "day%02d" $day) |
| 14 | 14 | ||
| 15 | echo "Initializing directory $dir/" | 15 | echo "Initializing directory $dir/" |
| 16 | mkdir -p $dir | 16 | rsync -av --ignore-existing skel/ ${dir}/ |
| 17 | 17 | ||
| 18 | advent_session=$(cat $cookiefile 2> /dev/null) && | 18 | advent_session=$(cat $cookiefile 2> /dev/null) && |
| 19 | echo "Downloading input ..." && | 19 | echo "Downloading input ..." && |
| 20 | curl "https://adventofcode.com/$year/day/$day/input" \ | 20 | curl "https://adventofcode.com/$year/day/$day/input" \ |
| 21 | -H "Cookie: session=$advent_session" > $dir/input.txt | 21 | -H "Cookie: session=$advent_session" > $dir/input.txt |
| 22 | |||
| 23 | exit 0 | ||
diff --git a/skel/Makefile b/skel/Makefile new file mode 100644 index 0000000..2fa98c0 --- /dev/null +++ b/skel/Makefile | |||
| @@ -0,0 +1 @@ | |||
| include ../aoc.mk | |||
diff --git a/skel/solution.cpp b/skel/solution.cpp new file mode 100644 index 0000000..f268bff --- /dev/null +++ b/skel/solution.cpp | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | #include <print> | ||
| 2 | #include <iostream> | ||
| 3 | |||
| 4 | const auto parse_input() { | ||
| 5 | |||
| 6 | } | ||
| 7 | |||
| 8 | void part1(const auto &input) { | ||
| 9 | |||
| 10 | } | ||
| 11 | |||
| 12 | void part2(const auto &input) { | ||
| 13 | |||
| 14 | } | ||
| 15 | |||
| 16 | int main() { | ||
| 17 | const auto input = parse_input(); | ||
| 18 | |||
| 19 | #ifndef NO_PART1 | ||
| 20 | part1(input); | ||
| 21 | #endif \ | ||
| 22 | |||
| 23 | #ifndef NO_PART2 | ||
| 24 | part2(input); | ||
| 25 | #endif | ||
| 26 | return 0; | ||
| 27 | } | ||
diff --git a/skel/tests/test1.input b/skel/tests/test1.input new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/skel/tests/test1.input | |||
diff --git a/skel/tests/test1.output b/skel/tests/test1.output new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/skel/tests/test1.output | |||
