From 55c0e82f420c54eb3766bc9830daf966ba6e68f7 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Mon, 1 Dec 2025 19:04:36 +0100 Subject: Update to blog post --- src/blog/2025-11-29-aoc-download/aoc-download.md | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src') diff --git a/src/blog/2025-11-29-aoc-download/aoc-download.md b/src/blog/2025-11-29-aoc-download/aoc-download.md index 5190aa9..a563955 100644 --- a/src/blog/2025-11-29-aoc-download/aoc-download.md +++ b/src/blog/2025-11-29-aoc-download/aoc-download.md @@ -86,3 +86,28 @@ opens up an editor and [Lynx](https://en.wikipedia.org/wiki/Lynx_(web_browser)) session to set me up to speed, but that is not as interesting. Happy coding! + +### Update 2025-12-01 + +An interesting addition to my script: now it can also download and save +the `` blocks and save them each in a separate file. This can +be useful because these blocks contain example input whose solution is +provided in the problem's page. The relevant code snippet, based on +`curl` and `sed`, is this: + +``` +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 +) +``` + -- cgit v1.3