From 183d2d20d311cdb296176496bba10e1c17f273fd Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Mon, 1 Dec 2025 18:57:14 +0100 Subject: aoc: download code blocks from input text --- aoc | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'aoc') diff --git a/aoc b/aoc index 13b89e7..d95a245 100755 --- a/aoc +++ b/aoc @@ -24,11 +24,25 @@ if [ ! -e input.txt ]; then curl "$url" -H "cookie: session=$AOC_SESSION_COOKIE" -o input.txt fi +# Download the problem statement page and split out the code blocks +url="https://adventofcode.com/$year/day/$daynozero" +curl "$url" | sed -n '/
/,/<\/code><\/pre>/ p' | (\
+	i=1
+	rm -f "code-$i.txt"
+	while read line; do
+		if [ "$line" = "
" ]; then + i=$((i + 1)) + rm -f "code-$i.txt" + else + echo "$line" | sed 's/<.*>//g' >> "code-$i.txt" + fi + done +) + # Open a tmux session with lynx in its own windows, and an editor and a # terminal in split view. printf 'adventofcode.com\tFALSE\t/\tTRUE\t2079722976\tsession\t%s' \ "$AOC_SESSION_COOKIE" > "$lynx_cookie_file" -url="https://adventofcode.com/$year/day/$daynozero" tmux new-session \; \ send-keys "$editor" C-m \; \ split-window -h \; \ -- cgit v1.3