Paul Waring

Freelance C Developer based in Manchester, UK

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.

#!/bin/bash

set -e
set -u
set -o pipefail
set -x

YEAR=$1
DAY=$2
PART=$3

cd ${YEAR}
make build/${DAY}${PART}
./build/${DAY}${PART} ./input/${DAY}.txt

cd -

Run tests

Running tests involves building the test suite executable. No input is required as test data is contained within the test suite.

#!/bin/bash

set -e
set -u
set -o pipefail

YEAR=$1
DAY=$2

cd ${YEAR}
make build/${DAY}t
./build/${DAY}t

cd -