summary refs log tree commit diff
path: root/prep.sh
diff options
context:
space:
mode:
authordzwdz2022-12-10 11:06:12 +0100
committerdzwdz2022-12-10 11:06:12 +0100
commit1481706ee8299b9e10004c776d6b5a709246b622 (patch)
treed369a9f1e85023cb9654bef97728a26efbc5d923 /prep.sh
parent36db7e1750f049234daf3cb228c674581d7cceb6 (diff)
add a script for fetching the input + examples
Diffstat (limited to 'prep.sh')
-rwxr-xr-xprep.sh10
1 files changed, 10 insertions, 0 deletions
diff --git a/prep.sh b/prep.sh
new file mode 100755
index 0000000..33a99d8
--- /dev/null
+++ b/prep.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+set -eu
+set -o pipefail
+
+DAY=$1
+CURLOPTS=--no-progress-meter
+
+curl $CURLOPTS https://adventofcode.com/2022/day/$DAY | awk '/<pre><code>/ {sub("<pre><code>", ""); CODE=1; IDX+=1} /<\/code>/ {CODE=0;} {if (CODE) print > sprintf("ex%d.in", IDX)}'
+curl $CURLOPTS -b ../cookie https://adventofcode.com/2022/day/$DAY/input > real.in
+echo "done :)"