Helper utilities for solving Advent of Code puzzles
Project description
adventofcode
Helper utilities for solving Advent of Code puzzles.
- Project scaffolding with
adventofcode init - No copy-pasting puzzle inputs into files.
- No need to use low-level file APIs to read your inputs.
- Performance reports for example inputs and puzzle inputs.
- Submit the answer immediately when your code returns the result 🏅
Usage
Setup
uv init
uv add adventofcode
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 py files look like this:
from adventofcode import AoC
def part1(inp: str):
return None
def part2(inp: str):
return None
aoc = AoC(part_1=part1, part_2=part2)
inp = """sample input"""
expected_result = None
aoc.assert_p1(inp, expected_result)
aoc.submit_p1()
expected_result = None
aoc.assert_p2(inp, expected_result)
aoc.submit_p2()
You write your solution in part1 and part2 functions.
aoc.assert_p1(inp, expected_result) will call your part1 function with inp and assert that the return matches expected_result.
aoc.submit_p1() will fetch your puzzle input from the adventofcode.com, cache it locally and call part1 with your puzzle input. If part1 returns a value that isn't None that value will be submitted as your puzzle answer.
Set your session cookie
Add the adventofcode.com session cookie value to your .env file or to your active session:
export AOC_SESSION="..."
[!NOTE] Setting AOC_SESSION will allow you to get your personal puzzle output (
aoc.get_input()) and submit your answers withaoc.submit_p1()andaoc.submit_p2().
Or build your workflow using the 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
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.0.tar.gz.
File metadata
- Download URL: adventofcode-25.0.tar.gz
- Upload date:
- Size: 7.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 |
ed3112e6f99490587028059cf2c8b43a537d37bcd630654c252da8aa81b13f80
|
|
| MD5 |
b1e4b1edcae5ee6c415ff071a7207b59
|
|
| BLAKE2b-256 |
c9ac4ca14966b044013a3b23aa51958a67842167f893361259567098d69966a4
|
Provenance
The following attestation bundles were made for adventofcode-25.0.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.0.tar.gz -
Subject digest:
ed3112e6f99490587028059cf2c8b43a537d37bcd630654c252da8aa81b13f80 - Sigstore transparency entry: 731668818
- Sigstore integration time:
-
Permalink:
anze3db/adventofcode@e8040603136ef2fbaf76178ad4e8f06ece82ce73 -
Branch / Tag:
refs/tags/25.0 - Owner: https://github.com/anze3db
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e8040603136ef2fbaf76178ad4e8f06ece82ce73 -
Trigger Event:
release
-
Statement type:
File details
Details for the file adventofcode-25.0-py3-none-any.whl.
File metadata
- Download URL: adventofcode-25.0-py3-none-any.whl
- Upload date:
- Size: 6.5 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 |
8a0361df8b08e62bca617a49646ddd4b6d2591d9b348c35853ec2dcb4bab3393
|
|
| MD5 |
a6cab491b63efc01b9a9961b82d5cacb
|
|
| BLAKE2b-256 |
71bb1dbdb12582b24ab81c345b472b58816ec165e6879b0ae9ae3c198dba2034
|
Provenance
The following attestation bundles were made for adventofcode-25.0-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.0-py3-none-any.whl -
Subject digest:
8a0361df8b08e62bca617a49646ddd4b6d2591d9b348c35853ec2dcb4bab3393 - Sigstore transparency entry: 731668827
- Sigstore integration time:
-
Permalink:
anze3db/adventofcode@e8040603136ef2fbaf76178ad4e8f06ece82ce73 -
Branch / Tag:
refs/tags/25.0 - Owner: https://github.com/anze3db
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e8040603136ef2fbaf76178ad4e8f06ece82ce73 -
Trigger Event:
release
-
Statement type: