Repository navigation
Highlights
Upgrading: run adventofcode benchmark for the whole folder once to move an existing README table to the new format. Until then, benchmarking a single day asks you to do that instead of overwriting the table.
New
adventofcode loginsets up your session cookie once for every year. It tells you where to find the cookie, checks it with adventofcode.com, and saves it to~/.config/adventofcode/session. No more copying the cookie into each year's.envfile.AOC_SESSIONin the environment or.envstill works and takes precedence, andadventofcode initoffers to log in when no cookie is set up.- A redesigned benchmark table in the README: one row per day with its fastest solution, stars instead of ✅/
⚠️ , and links to each solution file. Days with more than one solution get an Other versions table that compares each version to the fastest ("23× slower") instead of striking it through. The legend covers every status icon, and a line says which Python and platform the times were measured on. - Benchmark results are saved to
benchmarks.json, and the README table is rebuilt from it on every run. Benchmarking a single day updates only that day. The console shows how much each solution sped up or slowed down since the last run, and prints the errors of failing days. adventofcode runtells you how long until a puzzle unlocks, instead of failing with an error from adventofcode.com.- An expired or mistyped session cookie gets a clear message telling you to run
adventofcode login, instead of adventofcode.com's raw error. - Puzzle descriptions keep their formatting (#46).
print_p1()andprint_p2()show the highlighted parts in bold and code in color, andget_puzzle()takesformat="markdown"orformat="html"as well as the plain text it returned before.
Fixes
- Part 2 is only submitted once part 1 is solved. Before, a part 2 answer submitted too early got a "wrong level" response that was cached forever, so that answer could never be submitted again.
- "You gave an answer too recently" responses are no longer cached, so the answer is submitted again on the next run.
adventofcode initadds.cache*to.gitignore, and creates.gitignoreif it's missing..cachedidn't match the.cache.dbinput cache that Python 3.11 and 3.12 create on macOS, so puzzle inputs could end up in git.- Benchmarking a single day no longer fails to find variant rows (like
03-alt.py), breaks the table's total row when there are variants, or adds a slower variant's time to the totals. adventofcode benchmark ./2024works again: the day scripts were run with a path relative to the wrong directory.- Benchmark times are no longer misread when the answer itself contains "ms".
- File names with a variant suffix like
03-v2.pyare no longer treated as day 32. print_p2()says when part 2 isn't available yet instead of crashing, and doesn't cache that.AoC()can be created withoutpart_1/part_2functions, andsubmit_p1(answer)/submit_p2(answer)submit the answer you pass in, as the README describes.- Answers of
0are submitted instead of skipped.
Smaller changes
submit_p1()andsubmit_p2()return the outcome:"correct","incorrect","too_recent", and so on.adventofcode runexits with a non-zero code when something goes wrong.- Importing
adventofcodeno longer creates a.cachefile in the current directory; it's opened the first time an input or answer is cached. SetAOC_CACHEto keep it somewhere else. A cache created by another Python version gets a clear error instead of adbm.errortraceback. - Requests to adventofcode.com send a
User-Agentthat identifies the tool, as Advent of Code asks automated tools to do.
What's Changed
🧰 Maintenance
- Bump the "monthly" group with 3 updates across multiple ecosystems by @dependabot[bot] in #73
- Bump the "monthly" group with 3 updates across multiple ecosystems by @dependabot[bot] in #74
Other changes
- [pre-commit.ci] pre-commit autoupdate by @pre-commit-ci[bot] in #71
Full Changelog: 26.1...26.2
Contributors
Thank you to everyone who contributed to this release: @anze3db