-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunner.sh
More file actions
executable file
·28 lines (21 loc) · 873 Bytes
/
runner.sh
File metadata and controls
executable file
·28 lines (21 loc) · 873 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env bash
STARTING_DIR=$(pwd)
YEAR=$1
DAY=$2
# Create inputs dir for year, if missing:
[ ! -d ".inputs/" ] && {}
[ ! -d ".inputs/$YEAR/" ] && mkdir ".inputs/$YEAR/" && touch ".inputs/$YEAR/.gitkeep"
[[ ! -f ".inputs/$YEAR/day$DAY.input" && ! -f ".inputs/$YEAR/day0$DAY.input" ]] && {
echo -e "Fetshing input for year $YEAR day $DAY..."
./get-input.sh $YEAR $DAY || echo -e "Subprocess for fetching failed."
}
# Nim solution file:
FILE_SOLUTION="day$DAY.nim"
[ ! -f "./$YEAR/$FILE_SOLUTION" ] && FILE_SOLUTION="day0$DAY.input"
# In year directory:
cd "$YEAR" || { echo "could not cd into dir"; exit 1; }
[ ! -d ".inputs/" ] && ln -s ../.inputs/$YEAR/ .inputs
[ ! -d ".inputs/" ] && { echo -e "Failed to create inputs symlink, giving up."; exit 1; }
# Nim:
nim r --hints:off "$FILE_SOLUTION"
cd "$STARTING_DIR" || echo "could not cd back out of dir"