aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-12-13 14:01:54 +0100
committerThomas Voss <mail@thomasvoss.com> 2024-12-13 14:01:54 +0100
commitc84fbdd38f26b25d68cc94f0b60e45a08afea4ec (patch)
treeb87e44b67bc5f3e0b6bc744c6ffff0639e52d10a
parent7b1b7ae00819735e48772625faf0fb1f2d73653c (diff)
Add script to download inputs
-rw-r--r--.gitignore1
-rwxr-xr-xfetch-inputs17
2 files changed, 18 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index f7810eb..1c534da 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
__pycache__/
.clang-format
+.cookies
input
input-*
puzzle-[12]
diff --git a/fetch-inputs b/fetch-inputs
new file mode 100755
index 0000000..5161496
--- /dev/null
+++ b/fetch-inputs
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+find . \
+ -regextype egrep \
+ -mindepth 2 \
+ -maxdepth 2 \
+ -type d \
+ -regex '\./[0-9]{4}/[0-9]{2}' \
+ | while IFS=/ read _ y d
+do
+ file=$y/$d/input
+ [ -f "$file" ] && continue
+ >&2 printf 'Fetching %s/%s... ' $y $d
+ wget -q --load-cookies=.cookies -O "$file" \
+ "https://adventofcode.com/$y/day/${d#0}/input"
+ >&2 printf 'DONE\n' >&2
+done \ No newline at end of file