From d5c2821d589ef36f885bb4f92a6d6ca0bc4cc0e7 Mon Sep 17 00:00:00 2001 From: Orfeas <38209077+0xfea5@users.noreply.github.com> Date: Wed, 27 Aug 2025 04:16:05 +0300 Subject: Add ‘skel/‘ as template directory for each day MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aoc.mk | 32 ++++++++++++++++++++++++++++++++ init.sh | 4 +--- skel/Makefile | 1 + skel/solution.cpp | 27 +++++++++++++++++++++++++++ skel/tests/test1.input | 0 skel/tests/test1.output | 0 6 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 aoc.mk create mode 100644 skel/Makefile create mode 100644 skel/solution.cpp create mode 100644 skel/tests/test1.input create mode 100644 skel/tests/test1.output diff --git a/aoc.mk b/aoc.mk new file mode 100644 index 0000000..c7b7c87 --- /dev/null +++ b/aoc.mk @@ -0,0 +1,32 @@ +CXX = g++ +CXX_FLAGS = -std=c++23 +SOLUTION = solution.cpp +INPUT = input.txt +TARGET = ./solution +TESTS = $(wildcard tests/*.input) +TIMEOUT = 5 + +.PHONY: run tests force + +all: compile run + +compile: ${TARGET} + +${TARGET}: ${SOLUTION} + ${CXX} ${CXX_FLAGS} $? -o $@ + +force: + +tests: ${TESTS} + +tests/test%.input: tests/test%.output compile force + @diff <(timeout ${TIMEOUT} ${TARGET} < $@) <(cat $<) > /tmp/aoc.output \ + && echo -e "$@ [\e[0;32mok\e[m]" \ + || echo -e "$@ [\e[0;31mfail\e[m]" + @cat /tmp/aoc.output + +run: compile + timeout ${TIMEOUT} ${TARGET} < ${INPUT} + +clean: + rm -f ${TARGET} diff --git a/init.sh b/init.sh index 2877498..76dfeea 100755 --- a/init.sh +++ b/init.sh @@ -13,11 +13,9 @@ cookiefile=${3:-'./cookie'} dir=$(printf "day%02d" $day) echo "Initializing directory $dir/" -mkdir -p $dir +rsync -av --ignore-existing skel/ ${dir}/ advent_session=$(cat $cookiefile 2> /dev/null) && echo "Downloading input ..." && curl "https://adventofcode.com/$year/day/$day/input" \ -H "Cookie: session=$advent_session" > $dir/input.txt - -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 @@ +#include +#include + +const auto parse_input() { + +} + +void part1(const auto &input) { + +} + +void part2(const auto &input) { + +} + +int main() { + const auto input = parse_input(); + +#ifndef NO_PART1 + part1(input); +#endif \ + +#ifndef NO_PART2 + part2(input); +#endif + return 0; +} diff --git a/skel/tests/test1.input b/skel/tests/test1.input new file mode 100644 index 0000000..e69de29 diff --git a/skel/tests/test1.output b/skel/tests/test1.output new file mode 100644 index 0000000..e69de29 -- cgit v1.2.3