Advent of Code Wrapper Scripts

As C solutions need to be compiled, run and passed command line arguments (e.g. the puzzle input), I have written some simple wrapper scripts to manage this process.

Run solution

Running a solution involves building the executable and running it with the input for that day. I used to use a Makefile for this but as we are only compiling a small amount of code it is easier to just build and run it every time.

#!/bin/bash

set -e
set -u
set -o pipefail

YEAR=$1
DAY=$2

AOC_DIR=${PWD}
cd ${YEAR}/${DAY}
clang -Wall -Wextra -Werror --std=c99 -pedantic -I${AOC_DIR} ${DAY}.c ${DAY}_functions.c ${AOC_DIR}/aoc.c -o ${DAY}
./${DAY}
rm ${DAY}
cd -

Run tests

#!/bin/bash

set -e
set -u
set -o pipefail

YEAR=$1
DAY=$2

AOC_DIR=${PWD}
cd ${YEAR}/${DAY}
clang -Wall -Wextra -Werror --std=c99 -pedantic -I${AOC_DIR} -I${AOC_DIR}/Unity/src ${DAY}_tests.c ${DAY}_functions.c ${AOC_DIR}/aoc.c ${AOC_DIR}/Unity/src/unity.c -o ${DAY}_tests
./${DAY}_tests
rm ${DAY}_tests
cd -