summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOrfeas <38209077+0xfea5@users.noreply.github.com>2025-08-27 04:16:05 +0300
committerOrfeas <38209077+0xfea5@users.noreply.github.com>2025-09-01 04:51:37 +0300
commitd5c2821d589ef36f885bb4f92a6d6ca0bc4cc0e7 (patch)
tree268b9c82a4f26dc009eb852fb5419cc44ab81f01
parent.gitignore: ignore binaries, lsp cache and compile_commands.json (diff)
downloadaoc24-d5c2821d589ef36f885bb4f92a6d6ca0bc4cc0e7.tar.gz
aoc24-d5c2821d589ef36f885bb4f92a6d6ca0bc4cc0e7.zip
Add ‘skel/‘ as template directory for each day
-rw-r--r--aoc.mk32
-rwxr-xr-xinit.sh4
-rw-r--r--skel/Makefile1
-rw-r--r--skel/solution.cpp27
-rw-r--r--skel/tests/test1.input0
-rw-r--r--skel/tests/test1.output0
6 files changed, 61 insertions, 3 deletions
diff --git a/aoc.mk b/aoc.mk
new file mode 100644
index 0000000..c7b7c87
--- /dev/null
+++ b/aoc.mk
@@ -0,0 +1,32 @@
1CXX = g++
2CXX_FLAGS = -std=c++23
3SOLUTION = solution.cpp
4INPUT = input.txt
5TARGET = ./solution
6TESTS = $(wildcard tests/*.input)
7TIMEOUT = 5
8
9.PHONY: run tests force
10
11all: compile run
12
13compile: ${TARGET}
14
15${TARGET}: ${SOLUTION}
16 ${CXX} ${CXX_FLAGS} $? -o $@
17
18force:
19
20tests: ${TESTS}
21
22tests/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
28run: compile
29 timeout ${TIMEOUT} ${TARGET} < ${INPUT}
30
31clean:
32 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'}
13dir=$(printf "day%02d" $day) 13dir=$(printf "day%02d" $day)
14 14
15echo "Initializing directory $dir/" 15echo "Initializing directory $dir/"
16mkdir -p $dir 16rsync -av --ignore-existing skel/ ${dir}/
17 17
18advent_session=$(cat $cookiefile 2> /dev/null) && 18advent_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
23exit 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
4const auto parse_input() {
5
6}
7
8void part1(const auto &input) {
9
10}
11
12void part2(const auto &input) {
13
14}
15
16int 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