Helper utilities for solving Advent of Code puzzles
Project description
๐ adventofcode

Your framework for solving Advent Of Code puzzles ๐งฉ and benchmarking solutions ๐
- Project scaffolding with
uv run adventofcode init. - 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
This will generate the scripts for each day:
.
โโโ 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 2025 ๐
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
Before we can run these files we need to set up your session cookie. You can find the session cookie by going to [adventofcode.com] in your browser. Make sure you are logged in, then open your browser's developer tools and navigate to Application โ Storage โ Cookies. Look for the cookie named session and copy its value.
Then add the adventofcode.com session cookie value to your .env file:
# Set your Advent of Code session cookie below
# You can find it in your browser's developer tools after logging in to adventofcode.com.
# The name of the cookie is `session`.
AOC_SESSION="YOUR_SESSION_COOKIE_HERE"
AOC_YEAR=2025
or to your environment variables:
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 the same process repeats for
part2.
Benchmark all your solutions
You can benchmark your solutions with
uv run adventofcode benchmark
This will run each day's solution and parse the timing results from the output. The results will be printed to the console as well as added to your README.md.
If you are in a hurry you can also benchmark a single day's solution with
uv run adventofcode benchmark 05.py
Example console output:
Example README:
| Day | Status | Part 1 Time | Part 2 Time | Total Time |
|---|---|---|---|---|
| 01 | โ | 0.28ms ๐ข | 0.41ms ๐ข | 0.69ms ๐ข |
| 02 | โ | 0.76ms ๐ข | 1.13ms ๐ข | 1.89ms ๐ข |
| 03 | โ | 0.15ms ๐ข | 0.33ms ๐ข | 0.48ms ๐ข |
| 04 | โ | 21.43ms ๐ข | 4.79ms ๐ข | 26.22ms ๐ข |
| 05 | โ | 1.95ms ๐ข | 3.51ms ๐ข | 5.46ms ๐ข |
| 06 | โ | 3.04ms ๐ข | 3.91s ๐ด | 3.91s ๐ด |
| 07 | โ | 30.58ms ๐ข | 1.01s ๐ด | 1.04s ๐ด |
| 08 | โ | 0.42ms ๐ข | 0.60ms ๐ข | 1.02ms ๐ข |
| 09 | โ | 5.75ms ๐ข | 1.01s ๐ด | 1.02s ๐ด |
| 10 | โ | 2.85ms ๐ข | 3.05ms ๐ข | 5.90ms ๐ข |
| 11 | โ | 0.97ms ๐ข | 37.60ms ๐ข | 38.57ms ๐ข |
| 12 | โ | 30.75ms ๐ข | 31.96ms ๐ข | 62.71ms ๐ข |
| 13 | โ | 108.79ms ๐ก | 342.44ms ๐ก | 451.23ms ๐ก |
| 14 | โ | 3.03ms ๐ข | 380.22ms ๐ก | 383.25ms ๐ก |
| 15 | โ | 2.28ms ๐ข | 4.71ms ๐ข | 6.99ms ๐ข |
| 16 | โ | 80.55ms ๐ข | 124.54ms ๐ก | 205.09ms ๐ก |
| 17 | โ | 0.02ms ๐ข | 19.99ms ๐ข | 20.01ms ๐ข |
| 18 | โ | 5.66ms ๐ข | 6.98s ๐ด | 6.99s ๐ด |
| 19 | โ | 9.05ms ๐ข | 99.83ms ๐ข | 108.88ms ๐ก |
| 20 | โ | 47.46s ๐ด | 4.28s ๐ด | 51.74s ๐ด |
| 21 | โ | 0.22ms ๐ข | 0.25ms ๐ข | 0.47ms ๐ข |
| 22 | โ | 603.65ms ๐ก | 1.87s ๐ด | 2.47s ๐ด |
| 23 | โ | 223.80ms ๐ก | 222.87ms ๐ก | 446.67ms ๐ก |
| 24 | โ ๏ธ | 0.94ms ๐ข | - | 0.94ms ๐ข |
| 25 | โ | 6.02ms ๐ข | - | 6.02ms ๐ข |
| Total | 48.60s ๐ด | 20.34s ๐ด | 68.94s ๐ด |
Legend:
- ๐ข < 100ms
- ๐ก 100ms - 1s
- ๐ด > 1s
Using AoC class
Alternatively, you can build your own workflow using the lower level AoC class
from adventofcode import AoC
aoc = AoC() # defaults to current year and parses the day from the filename (e.g. 01.py will be 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 to the first part of the puzzle
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
Happy solving ๐
Enjoy and have fun!
Similar projects
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file adventofcode-25.12.tar.gz.
File metadata
- Download URL: adventofcode-25.12.tar.gz
- Upload date:
- Size: 144.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
384bf206c26b1210fd8686c7cd9de1cdf92c0614922def562132b1ce91523302
|
|
| MD5 |
ecf37f6cc143009c2d2d38b804c4f512
|
|
| BLAKE2b-256 |
539094f61ae24720ad744bc2e430697b0d894dbb05c191ee6b4c923a4585a954
|
Provenance
The following attestation bundles were made for adventofcode-25.12.tar.gz:
Publisher:
publish.yml on anze3db/adventofcode
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
adventofcode-25.12.tar.gz -
Subject digest:
384bf206c26b1210fd8686c7cd9de1cdf92c0614922def562132b1ce91523302 - Sigstore transparency entry: 760816612
- Sigstore integration time:
-
Permalink:
anze3db/adventofcode@40bc8fd7c816fa40730cd12031b5c0a4a7e60291 -
Branch / Tag:
refs/tags/25.12 - Owner: https://github.com/anze3db
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@40bc8fd7c816fa40730cd12031b5c0a4a7e60291 -
Trigger Event:
release
-
Statement type:
File details
Details for the file adventofcode-25.12-py3-none-any.whl.
File metadata
- Download URL: adventofcode-25.12-py3-none-any.whl
- Upload date:
- Size: 14.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c3aabb1a5c08bef0c325f4873be445057ab4aa4027a8aea031ec91d3cb1c87c
|
|
| MD5 |
8fd263e085ecbc58cde0445f463fac58
|
|
| BLAKE2b-256 |
4ecbe667359edee33d05220371b2572e152598c0f4d1ff1c7e44bbd54df27253
|
Provenance
The following attestation bundles were made for adventofcode-25.12-py3-none-any.whl:
Publisher:
publish.yml on anze3db/adventofcode
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
adventofcode-25.12-py3-none-any.whl -
Subject digest:
9c3aabb1a5c08bef0c325f4873be445057ab4aa4027a8aea031ec91d3cb1c87c - Sigstore transparency entry: 760816613
- Sigstore integration time:
-
Permalink:
anze3db/adventofcode@40bc8fd7c816fa40730cd12031b5c0a4a7e60291 -
Branch / Tag:
refs/tags/25.12 - Owner: https://github.com/anze3db
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@40bc8fd7c816fa40730cd12031b5c0a4a7e60291 -
Trigger Event:
release
-
Statement type: