commit 15902a524a76bf1b66c399aac1469d9399cbc573
parent 542b61b74650481fe6ba9e123a648cc660b922a9
Author: bsandro <brian.drosan@gmail.com>
Date: Fri, 10 Dec 2021 23:20:43 +0200
Script to compile/run all of the puzzles available at once
Diffstat:
15 files changed, 91 insertions(+), 39 deletions(-)
diff --git a/day01/Makefile b/day01/Makefile
@@ -14,10 +14,13 @@ clean:
rm -f $(OBJ) $(NAME)
%.o : %.c $(DEPS)
- $(CC) $(CFLAGS) -c $< -o $@
+ @$(CC) $(CFLAGS) -c $< -o $@
$(NAME): $(OBJ)
- $(CC) $(OBJ) -o $@ $(LDFLAGS)
+ @$(CC) $(OBJ) -o $@ $(LDFLAGS)
run: $(NAME)
- ./$(NAME) input.txt
+ @./$(NAME) input.txt
+
+test: $(NAME)
+ @./$(NAME) test.txt
diff --git a/day01/test.txt b/day01/test.txt
@@ -0,0 +1,10 @@
+199
+200
+208
+210
+200
+207
+240
+269
+260
+263
diff --git a/day02/Makefile b/day02/Makefile
@@ -14,10 +14,13 @@ clean:
rm -f $(OBJ) $(NAME)
%.o : %.c $(DEPS)
- $(CC) $(CFLAGS) -c $< -o $@
+ @$(CC) $(CFLAGS) -c $< -o $@
$(NAME): $(OBJ)
- $(CC) $(OBJ) -o $@ $(LDFLAGS)
+ @$(CC) $(OBJ) -o $@ $(LDFLAGS)
run: $(NAME)
- ./$(NAME) input.txt
+ @./$(NAME) input.txt
+
+test: $(NAME)
+ @./$(NAME) test.txt
diff --git a/day02/test.txt b/day02/test.txt
@@ -0,0 +1,6 @@
+forward 5
+down 5
+forward 8
+up 3
+down 8
+forward 2
diff --git a/day03/Makefile b/day03/Makefile
@@ -14,10 +14,13 @@ clean:
rm -f $(OBJ) $(NAME)
%.o : %.c $(DEPS)
- $(CC) $(CFLAGS) -c $< -o $@
+ @$(CC) $(CFLAGS) -c $< -o $@
$(NAME): $(OBJ)
- $(CC) $(OBJ) -o $@ $(LDFLAGS)
+ @$(CC) $(OBJ) -o $@ $(LDFLAGS)
run: $(NAME)
- ./$(NAME) input.txt
+ @./$(NAME) input.txt
+
+test: $(NAME)
+ @./$(NAME) test.txt
diff --git a/day03/puzzle2.c b/day03/puzzle2.c
@@ -78,7 +78,7 @@ int puzzle2(const char *filename) {
}
if (oxygen.count != 1 || scrubber.count != 1) {
- fprintf(stderr, "Filter failed :C");
+ fprintf(stderr, "Filter failed\n");
goto finish;
}
diff --git a/day03/test.txt b/day03/test.txt
@@ -0,0 +1,12 @@
+00100
+11110
+10110
+10111
+10101
+01111
+00111
+11100
+10000
+11001
+00010
+01010
diff --git a/day04/Makefile b/day04/Makefile
@@ -14,13 +14,13 @@ clean:
rm -f $(OBJ) $(NAME)
%.o : %.c $(DEPS)
- $(CC) $(CFLAGS) -c $< -o $@
+ @$(CC) $(CFLAGS) -c $< -o $@
$(NAME): $(OBJ)
- $(CC) $(OBJ) -o $@ $(LDFLAGS)
+ @$(CC) $(OBJ) -o $@ $(LDFLAGS)
run: $(NAME)
- ./$(NAME) input.txt
+ @./$(NAME) input.txt
test: $(NAME)
- ./$(NAME) test.txt
+ @./$(NAME) test.txt
diff --git a/day05/Makefile b/day05/Makefile
@@ -14,13 +14,13 @@ clean:
rm -f $(OBJ) $(NAME)
%.o : %.c $(DEPS)
- $(CC) $(CFLAGS) -c $< -o $@
+ @$(CC) $(CFLAGS) -c $< -o $@
$(NAME): $(OBJ)
- $(CC) $(OBJ) -o $@ $(LDFLAGS)
+ @$(CC) $(OBJ) -o $@ $(LDFLAGS)
run: $(NAME)
- ./$(NAME) input.txt
+ @./$(NAME) input.txt
test: $(NAME)
- ./$(NAME) test.txt
+ @./$(NAME) test.txt
diff --git a/day06/Makefile b/day06/Makefile
@@ -14,13 +14,13 @@ clean:
rm -f $(OBJ) $(NAME)
%.o : %.c $(DEPS)
- $(CC) $(CFLAGS) -c $< -o $@
+ @$(CC) $(CFLAGS) -c $< -o $@
$(NAME): $(OBJ)
- $(CC) $(OBJ) -o $@ $(LDFLAGS)
+ @$(CC) $(OBJ) -o $@ $(LDFLAGS)
run: $(NAME)
- ./$(NAME) input.txt
+ @./$(NAME) input.txt
test: $(NAME)
- ./$(NAME) test.txt
+ @./$(NAME) test.txt
diff --git a/day07/Makefile b/day07/Makefile
@@ -14,16 +14,16 @@ clean:
rm -f $(OBJ) $(NAME)
%.o : %.c $(DEPS)
- $(CC) $(CFLAGS) -c $< -o $@
+ @$(CC) $(CFLAGS) -c $< -o $@
$(NAME): $(OBJ)
- $(CC) $(OBJ) -o $@ $(LDFLAGS)
+ @$(CC) $(OBJ) -o $@ $(LDFLAGS)
run: $(NAME)
- ./$(NAME) input.txt
+ @./$(NAME) input.txt
test: $(NAME)
- ./$(NAME) test.txt
+ @./$(NAME) test.txt
brute: $(NAME)
- ./$(NAME) -b input.txt
+ @./$(NAME) -b input.txt
diff --git a/day08/Makefile b/day08/Makefile
@@ -14,13 +14,13 @@ clean:
rm -f $(OBJ) $(NAME)
%.o : %.c $(DEPS)
- $(CC) $(CFLAGS) -c $< -o $@
+ @$(CC) $(CFLAGS) -c $< -o $@
$(NAME): $(OBJ)
- $(CC) $(OBJ) -o $@ $(LDFLAGS)
+ @$(CC) $(OBJ) -o $@ $(LDFLAGS)
run: $(NAME)
- ./$(NAME) input.txt
+ @./$(NAME) input.txt
test: $(NAME)
- ./$(NAME) test.txt
+ @./$(NAME) test.txt
diff --git a/day09/Makefile b/day09/Makefile
@@ -14,13 +14,13 @@ clean:
rm -f $(OBJ) $(NAME)
%.o : %.c $(DEPS)
- $(CC) $(CFLAGS) -c $< -o $@
+ @$(CC) $(CFLAGS) -c $< -o $@
$(NAME): $(OBJ)
- $(CC) $(OBJ) -o $@ $(LDFLAGS)
+ @$(CC) $(OBJ) -o $@ $(LDFLAGS)
run: $(NAME)
- ./$(NAME) input.txt
+ @./$(NAME) input.txt
test: $(NAME)
- ./$(NAME) -t test.txt
+ @./$(NAME) -t test.txt
diff --git a/day10/Makefile b/day10/Makefile
@@ -14,13 +14,13 @@ clean:
rm -f $(OBJ) $(NAME)
%.o : %.c $(DEPS)
- $(CC) $(CFLAGS) -c $< -o $@
+ @$(CC) $(CFLAGS) -c $< -o $@
$(NAME): $(OBJ)
- $(CC) $(OBJ) -o $@ $(LDFLAGS)
+ @$(CC) $(OBJ) -o $@ $(LDFLAGS)
run: $(NAME)
- ./$(NAME) input.txt
+ @./$(NAME) input.txt
test: $(NAME)
- ./$(NAME) test.txt
+ @./$(NAME) test.txt
diff --git a/run.sh b/run.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+days=day*
+base=$(pwd)
+cmd="run"
+
+if [[ -n "$1" ]]; then
+ cmd=$1
+fi
+
+for day in $days; do
+ cd $day
+ make -j2 $cmd
+ cd $base
+done