aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/blog/2025-11-29-aoc-download/aoc-download.md25
1 files changed, 25 insertions, 0 deletions
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))
86session to set me up to speed, but that is not as interesting. 86session to set me up to speed, but that is not as interesting.
87 87
88Happy coding! 88Happy coding!
89
90### Update 2025-12-01
91
92An interesting addition to my script: now it can also download and save
93the `<code>` blocks and save them each in a separate file. This can
94be useful because these blocks contain example input whose solution is
95provided in the problem's page. The relevant code snippet, based on
96`curl` and `sed`, is this:
97
98```
99url="https://adventofcode.com/$year/day/$daynozero"
100curl "$url" | sed -n '/<pre><code>/,/<\/code><\/pre>/ p' | (\
101 i=1
102 rm -f "code-$i.txt"
103 while read line; do
104 if [ "$line" = "</code></pre>" ]; then
105 i=$((i + 1))
106 rm -f "code-$i.txt"
107 else
108 echo "$line" | sed 's/<.*>//g' >> "code-$i.txt"
109 fi
110 done
111)
112```
113

Generated with cgit - Back to sebastiano.tronto.net