Advent-of-code-py
Advent of Code helper CLI and library for python projects.
Status & Info:
| License | Project Version |
|---|---|
Installation
Requires Python 3.11 or newer.
Add advent-of-code-py to a project with uv:
uv add advent-of-code-py
OR install only the CLI as a tool:
uv tool install advent-of-code-py
OR use pip:
pip install advent-of-code-py
Usage
Session configuration
advent-of-code-py needs your session cookie. You can get it from your browser's cookies while logged in to the Advent of Code website. Add it to the config with a name of your choice:
advent-of-code-py config add <session-name> <session-value>
You can add multiple sessions. The config file is created only readable by your user as it contains secrets.
advent-of-code-py config list # list all sessions
advent-of-code-py config remove <name> # remove a session
CLI
# download input of latest unlocked puzzle for all sessions
advent-of-code-py download
# download specific years, days and sessions (options can be repeated)
advent-of-code-py download -y 2024 -d 1 -d 2 -s <session-name>
# delete cached inputs (defaults to every year, day and session)
advent-of-code-py remove -y 2024 -d 1
From 2025 onward Advent of Code has 12 puzzles per year instead of 25.
Library
Use the solve or submit decorator on a function which takes puzzle input as a string and returns the answer.
import advent_of_code_py
@advent_of_code_py.submit(2018, 3, 1, session_list=["<session-name>"])
def puzzle_2018_3_1(data):
# do some calculation with data and return final output
return final_output
@advent_of_code_py.solve(2018, 3, 2)
def puzzle_2018_3_2(data):
return final_output
Call the decorated function to run it:
puzzle_2018_3_1()
When called without arguments the input of each session is downloaded (and cached) and the function runs once per
session. If session_list is not provided all sessions present in the config are used.
solveprints the answer.submitsubmits the answer to the Advent of Code server and prints whether it was correct. Already submitted answers are not submitted again and a submission within one minute of the previous one is blocked.
You can also pass input directly, e.g. for the puzzle's example input:
puzzle_2018_3_2("example input")
The call returns a dictionary of session name to answer. If the function returns None nothing is printed or
submitted for that session.
Creating a CLI for solutions
Use the Initializer and advent_runner to create a CLI for your solutions, so you can run them without
modifying python files every time.
@advent_of_code_py.advent_runner
def main_cli():
initializer = advent_of_code_py.Initializer()
initializer.add(p_3_1=puzzle_2018_3_1, p_3_2=puzzle_2018_3_2)
# add other functions ...
return initializer
Set main_cli as a script entry point in your pyproject.toml:
[project.scripts]
aoc = "my_package.cli:main_cli"
Then:
aoc list # list all functions and their alias
aoc run p_3_1 # run a function by alias
aoc all # run all functions
Development
uv sync
uv run ruff check .
uv run ruff format --check .
uv run pytest
uv run nox # run checks against all supported Python versions
Metadata
Release files for advent-of-code-py 0.5.0
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 |
|---|---|---|---|---|
| advent_of_code_py-0.5.0.tar.gz | 14.5 kB | Without provenance | Details for advent_of_code_py-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| advent_of_code_py-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for advent_of_code_py-0.5.0-py3-none-any.whl |
Total release size: 28.4 kB
Release files / advent_of_code_py-0.5.0.tar.gz
| Download URL | advent_of_code_py-0.5.0.tar.gz |
|---|---|
| Size | 14.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1bbdef34e2886094a4d902726531614ee9a7269b4013d7d3e39e36a0986bf586
|
|
BLAKE2b-256 checksum How to use checksums |
37f4fdad0dca7b24b0d8b1361f9faf8dda5f47b94b8afcfe6eb7e86da02810d5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / advent_of_code_py-0.5.0-py3-none-any.whl
| Download URL | advent_of_code_py-0.5.0-py3-none-any.whl |
|---|---|
| Size | 13.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ba58f790fc88e36d775c6500e45a9a6178e5ea45902953f11eeca3652b738dde
|
|
BLAKE2b-256 checksum How to use checksums |
3541a37829d20cf55e3c612d4a8f7eddec9cb4340d32d103c654d35fa1ee9655
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for advent-of-code-py 0.5.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.