-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit-day-2024.sh
52 lines (43 loc) · 1.37 KB
/
init-day-2024.sh
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/bash
year="2024"
cookie=$(cat session.cookie)
input_prefix="input"
sample_prefix="example"
# Example comes before input alphabetically, so it shows up in front in the program-tester.sh
if [[ $1 =~ ^[[:digit:]]{1}$ ]]; then
d_fol="0$1"
else
d_fol=$1
fi
echo $d_fol
if [[ "$1" ]]; then
if ! [[ -d "$1" ]]; then
echo "Creating folder for problem $1"
mkdir "$year/$d_fol"
mkdir "$year/$d_fol/data"
mkdir "$year/$d_fol/code"
fi
cd "$year/$d_fol/data"
# Download input from advent of code
input_file="${input_prefix}.in"
if ! [[ -f "$input_file" ]]; then
echo "Downloading input for problem $1"
# Don't DDOS! So check if file exists already
curl "https://adventofcode.com/$year/day/$1/input" --cookie "session=$cookie" > "$input_file"
fi
# Add empty file so there are not that many lines when showing input instead
input_ans_file="${input_prefix}.ans"
if ! [[ -f "$input_ans_file" ]]; then
echo "Create empty input answer file"
touch "$input_ans_file"
fi
# Prepare dummy python solution
# solution_file="$1.py"
# if ! [[ -f "$solution_file" ]]; then
# echo "Create dummy python solution $solution_file"
# cp "../dummy.py" "$solution_file"
# fi
# nvim "$solution_file" "${sample_prefix}.in" "${sample_prefix}.ans" -c "norm G$"
else
echo "Supply some number as first argument to initialize a problem!"
fi