🎄 adventofcode

Your framework for solving Advent Of Code puzzles 🧩 and benchmarking solutions 🚀
- Project scaffolding with
uv run adventofcode init. - Set up your session cookie once, for every year, with
uv run adventofcode login. - Assert and submit your solutions with
uv run adventofcode run. - Benchmark all your solutions with
uv run adventofcode benchmark. - No copy-pasting puzzle inputs or loading inputs from files.
- Submit the answer immediately when your code returns the result. 🏅
Table of Contents
- Setup
- Session cookie
- Run and submit your solution
- Benchmark all your solutions
- Using AoC class
- Happy solving 🎄
- Similar projects
Setup
uv init
uv add adventofcode
uv run adventofcode init
If you haven't set up your session cookie yet, init asks you to log in (see Session cookie), or you can run uv run adventofcode login yourself.
init generates the scripts for each day (12 puzzles since 2025, 25 before that), a .env file with the year, and adds .env and the cached puzzle inputs (.cache*) to .gitignore:
.
├── 01.py
├── 02.py
├── 03.py
├── 04.py
├── 05.py
├── 06.py
├── 07.py
├── 08.py
├── 09.py
├── 10.py
├── 11.py
├── 12.py
├── main.py
├── pyproject.toml
├── README.md
└── uv.lock
1 directory, 16 files
All the generated Python files look like this:
"""🎄 Solution for Day 1 of Advent of Code 2026 🎄
Usage:
uv run adventofcode run 01.py
"""
inp = """your input"""
part1_asserts = [
(inp, None),
]
part2_asserts = [
(inp, None),
]
def part1(inp: str) -> str | int | None:
return None
def part2(inp: str) -> str | int | None:
return None
Session cookie
To fetch your puzzle inputs and submit answers, adventofcode needs your adventofcode.com session cookie. Set it up once with
uv run adventofcode login
It tells you where to find the cookie named session in the developer tools. Paste its value, and login checks it with adventofcode.com and saves it to ~/.config/adventofcode/session (only you can read the file), so every Advent of Code folder on your computer uses it. adventofcode init offers to log in when no cookie is set up yet.
Session cookies expire after about a month. When yours does, adventofcode run tells you, and you run adventofcode login again.
To use a different cookie in one folder, set AOC_SESSION in that folder's .env file, or in your environment. It takes precedence over the saved one:
export AOC_SESSION="..."
Run and submit your solution
Implement your solution in part1 and part2 functions and run
uv run adventofcode run 01.py
This will:
- Run your day 1,
part1function with the inputs provided in thepart1_assertsiterable and compare them with the expected values. If the function's return value doesn't match the expected answer, the command will stop. Hint: Each puzzle usually contains example input and an expected answer—these make for great asserts! - If all the
part1_assertspass,part1will be called with your puzzle input fetched from adventofcode.com using your session cookie. - If
part1returns a non-None value for your puzzle input, that value will be submitted to adventofcode.com as your part 1 answer using your session cookie. All answer submissions are cached, so each unique answer will only be submitted once. - If your answer was correct (or part 1 was already solved), the same process repeats for
part2. Part 2 is never submitted while part 1 is still unsolved. - If adventofcode.com asks you to wait before submitting again, nothing is cached: rerun the command once the wait is over.
- Running a day before its puzzle unlocks (midnight EST) tells you how long you have left to wait.
Benchmark all your solutions
You can benchmark your solutions with
uv run adventofcode benchmark
This runs every day's solution (including variants like 03-numpy.py), shows the times in a live table in the console, saves the results to benchmarks.json and rebuilds the benchmark table in your README.md from them. Commit benchmarks.json along with your README.
If you are in a hurry you can also benchmark a single day's solution with
uv run adventofcode benchmark 05.py
This only reruns day 5 and keeps the stored results for every other day. The console shows how much faster or slower each solution got since the last run.
The README gets one row per day with its fastest solution. If you have more than one solution for a day (06.py, 06-numpy.py, 06-alt.py), the Other versions table compares them all to the fastest one.
Upgrading from an older version? The first time, run
uv run adventofcode benchmarkfor the whole folder. It benchmarks every day and migrates your README table to the new format. Until then, benchmarking a single day asks you to run the full benchmark instead, so the rest of your table isn't lost.
Here's the table it generated for anze3db/adventofcode2025, with the 2025 solutions:
| Day | Stars | Part 1 | Part 2 | Total | Solution |
|---|---|---|---|---|---|
| 01 | ⭐⭐ | 0.07ms 🟢 | 0.08ms 🟢 | 0.15ms 🟢 | 01.py |
| 02 | ⭐⭐ | 0.10ms 🟢 | 0.12ms 🟢 | 0.22ms 🟢 | 02.py |
| 03 | ⭐⭐ | 0.05ms 🟢 | 0.14ms 🟢 | 0.19ms 🟢 | 03.py |
| 04 | ⭐⭐ | 0.01ms 🟢 | 0.34ms 🟢 | 0.35ms 🟢 | 04-numpy.py · 2 versions |
| 05 | ⭐⭐ | 0.24ms 🟢 | 0.08ms 🟢 | 0.32ms 🟢 | 05.py |
| 06 | ⭐⭐ | 0.07ms 🟢 | 0.04ms 🟢 | 0.11ms 🟢 | 06.py |
| 07 | ⭐⭐ | 0.02ms 🟢 | 0.11ms 🟢 | 0.13ms 🟢 | 07.py |
| 08 | ⭐⭐ | 0.31ms 🟢 | 0.40ms 🟢 | 0.71ms 🟢 | 08-numpy.py · 2 versions |
| 09 | ⭐⭐ | 0.07ms 🟢 | 0.47ms 🟢 | 0.54ms 🟢 | 09-numpy.py · 2 versions |
| 10 | ⭐⭐ | 0.47ms 🟢 | 2.89ms 🟢 | 3.36ms 🟢 | 10-bareiss.py · 3 versions |
| 11 | ⭐⭐ | 0.06ms 🟢 | 0.23ms 🟢 | 0.29ms 🟢 | 11.py |
| 12 | ⭐⭐ | 0.04ms 🟢 | - | 0.04ms 🟢 | 12.py |
| Total | 24 ⭐ | 1.51ms 🟢 | 4.90ms 🟢 | 6.41ms 🟢 |
Other versions
| Day | Solution | Stars | Part 1 | Part 2 | Total | vs fastest |
|---|---|---|---|---|---|---|
| 04 | 04-numpy.py | ⭐⭐ | 0.01ms | 0.34ms | 0.35ms | 🏆 fastest |
| 04 | 04.py | ⭐⭐ | 5.50ms | 12.82ms | 18.32ms | 52× slower |
| 08 | 08-numpy.py | ⭐⭐ | 0.31ms | 0.40ms | 0.71ms | 🏆 fastest |
| 08 | 08.py | ⭐⭐ | 470.59ms | 448.94ms | 919.53ms | 1295× slower |
| 09 | 09-numpy.py | ⭐⭐ | 0.07ms | 0.47ms | 0.54ms | 🏆 fastest |
| 09 | 09.py | ⭐⭐ | 9.54ms | 120.99ms | 130.53ms | 242× slower |
| 10 | 10-bareiss.py | ⭐⭐ | 0.47ms | 2.89ms | 3.36ms | 🏆 fastest |
| 10 | 10-numpy.py | ⭐⭐ | 0.62ms | 9.90ms | 10.52ms | 3.1× slower |
| 10 | 10.py | ⭐⭐ | 172.34ms | 209.66ms | 382.00ms | 114× slower |
Legend: 🟢 < 100ms · 🟡 100ms - 1s · 🔴 > 1s · ⭐ part solved · ✏️ no answer yet · 🕑 not unlocked yet · ❌ error · ⏰ timed out (> 5 min)
Measured with Python 3.14.0 on macOS arm64, last run 2026-11-29.
Using AoC class
Alternatively, you can build your own workflow using the lower level AoC class
from adventofcode import AoC
aoc = AoC() # defaults to AOC_YEAR (or the current year) and parses the day from the filename (e.g. 01.py is day 1)
aoc.print_p1() # prints the first part of the puzzle
inp = aoc.get_input() # returns the input as a string
# solve the puzzle here
...
aoc.submit_p1("part 1 answer") # submits the answer, returns "correct", "incorrect", "too_recent", ...
aoc.print_p2() # prints the second part of the puzzle
# solve the puzzle here
...
aoc.submit_p2("part 2 answer") # submits the answer to the second part of the puzzle
print_p1() and print_p2() show the puzzle in the terminal with its highlighted parts in bold, as on adventofcode.com. They often matter: in the examples, they mark what counts. To keep the description elsewhere, get_puzzle() returns it as plain text, Markdown or HTML:
aoc.get_puzzle(1) # part 1 as plain text
aoc.get_puzzle(1, format="markdown") # highlights in bold, code as code
aoc.get_puzzle(2, format="html") # the page's <article> as it is
In Markdown, an example with highlighted parts stays an HTML <pre> block, since Markdown can't highlight inside a code block. Markdown previews (GitHub, VS Code, ...) still show the highlights.
Happy solving 🎄
Enjoy and have fun!
Similar projects
Metadata
Release files for adventofcode 26.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| adventofcode-26.2.tar.gz | 23.3 kB | With provenance | Details for adventofcode-26.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| adventofcode-26.2-py3-none-any.whl | Python 3 | none | any | Details for adventofcode-26.2-py3-none-any.whl |
Total release size: 48.2 kB
Release files / adventofcode-26.2.tar.gz
| Download URL | adventofcode-26.2.tar.gz |
|---|---|
| Size | 23.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4df7e0b416b6041e561ea13f8192e79b9c05621b98fbbd9a72fbfd82748e6c18
|
|
BLAKE2b-256 checksum How to use checksums |
c0d88f4ce471e3b07b56e4f3976128a3a53dffba3ac13ecef64ce6e882c496d9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logRelease files / adventofcode-26.2-py3-none-any.whl
| Download URL | adventofcode-26.2-py3-none-any.whl |
|---|---|
| Size | 24.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c3e361eaf1bf4d5458163bf534198a7df7edf5da7715ebd230de8d15d3620a22
|
|
BLAKE2b-256 checksum How to use checksums |
73494c5cab4627ff89a58f32e79597b836c78c2b2d2ac4205fe644ddc14b3155
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logSecurity for adventofcode 26.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for adventofcode-26.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.