A Python CLI and library for interacting with the Advent of Code API to fetch puzzles, download inputs, and submit answers.
Project description
Python Advent of Code 🎄
A Python CLI and library for interacting with the Advent of Code API.
Key Features
- 🌐 Opens the daily puzzle page in your browser
- 🚀 Downloads your personalised puzzle inputs
- 📂 Generates new solution files from a template
- ✅ Tests and directly submits your solutions
Installation
To use the project, you can simply install it using pip:
pip install python-aoc
It can then be used in the command line and imported as a library with pyaoc.
Configuration
To interact with the Advent of Code API, you must provide your session token. This tool reads the token from an environment variable named AOC_SESSION, which can be set manually or through the following command:
pyaoc session set <your-session-token>
Quick Start
The most common workflow is to create, test, and submit a solution.
-
Create the files for a new day:
The following command will create a
day-5/directory, download the input intoday-5/input.txt, create aday-5/test.txtfile to hold a test input, and create aday-5/main.pyscript file from the defaultpython-aoctemplate:pyaoc create 5 2025
-
Test your solution against a known answer:
Once you have completed your solution to the puzzle, written in a
solvefunction which takes in the path to an input file, you can test it against a known answer for an example case intest.txt:# Assuming the example answer is 123 pyaoc test day-5/main.py 123 --test-input-path day-5/test.txt
-
Submit your final solution:
Then, the final solution for the specified part can be submitted using the
submitcommand:pyaoc submit day-5/main.py 1 --day 5 --year 2025 --input-path day-5/input.txt
For the complete list of CLI commands and their arguments, run pyaoc --help.
Library usage
You can also import and use the core functions in your own Python scripts:
import pyaoc
# Sets the session token (if it's not already set as an environment variable)
pyaoc.set_session("your-session-token")
try:
# Get puzzle input for Dec 1, 2023
puzzle_input = pyaoc.get_day_input(day=1, year=2023)
print(puzzle_input[:50]) # Print the first 50 characters
except Exception as e:
print(f"An error occurred: {e}")
License
This project is licensed under the MIT License. See the LICENSE file for details.
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 python_aoc-0.1.2.tar.gz.
File metadata
- Download URL: python_aoc-0.1.2.tar.gz
- Upload date:
- Size: 14.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
91a9d6e6838d7e043efcb1d6e4463f3cba21403f86373394de59fe95464956c2
|
|
| MD5 |
9f189709d48041ee3dd3e70a64cde0c7
|
|
| BLAKE2b-256 |
2ebc5a6f71f4cb57cab5f93bc2202711d0df3f9021f8b804942599d00e016995
|
File details
Details for the file python_aoc-0.1.2-py3-none-any.whl.
File metadata
- Download URL: python_aoc-0.1.2-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
66d6aa8a42dd50c29b601b1e2957c15a5962d10057059b2087fae4e0fde7c59e
|
|
| MD5 |
453ee25dacc782a485355ef001c6607f
|
|
| BLAKE2b-256 |
4a57ab011a885f570d77f277a2c82f95cea1d893db71eaaa8ca7c6c24dd1b1ff
|