Skip to main content

Python Advent of Code 🎄

PyPI Version

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 must be set before use.

To verify that your session cookie is set up correctly, you can display it using the following command:

pyaoc session

Quick Start

The most common workflow is to create, test, and submit a solution.

  1. Create the files for a new day:

    The following command will create a day-5/ directory, download the input into day-5/input.txt, create a day-5/test.txt file to hold a test input, and create a day-5/main.py script file from the default python-aoc template:

    pyaoc create 5 2025
    
  2. Test your solution against a known answer:

    Once you have completed your solution to the puzzle, written in a solve function which takes in the path to an input file, you can test it against a known answer for an example case in test.txt:

    # Assuming the example answer is 123
    pyaoc test day-5/main.py 123 --test-input-path day-5/test.txt
    
  3. Submit your final solution:

    Then, the final solution for the specified part can be submitted using the submit command:

    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 for this script
pyaoc.set_session("your-session-token")

try:
    # Get puzzle input for Day 1, 2023
    puzzle_input = pyaoc.get_day_input(day=1, year=2023)
    print(puzzle_input[:50]) # Prints the first 50 characters
except Exception as e:
    print(f"An error occurred: {e}")

Development Setup

This project uses uv as a package and virtual environment manager. To set up the project for development, follow these steps:

  1. Clone the repository:

    git clone https://github.com/benjaminrall/python-aoc.git
    cd python-aoc
    
  2. Run the application using uv:

    uv run pyaoc
    

    This will automatically install any required packages and run the command in a virtual environment, including any changes to the source code.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Metadata

Release files for python-aoc 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-aoc 0.1.6
File Size Uploaded Provenance Actions
python_aoc-0.1.6.tar.gz 15.3 kB Without provenance Details for python_aoc-0.1.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for python-aoc 0.1.6
File Interpreter ABI Platform Actions
python_aoc-0.1.6-py3-none-any.whl Python 3 none any Details for python_aoc-0.1.6-py3-none-any.whl

Total release size: 25.9 kB

Release files / python_aoc-0.1.6.tar.gz

Download URL python_aoc-0.1.6.tar.gz
Size 15.3 kB
Tags Source
SHA-256 checksum
How to use checksums
a4ece40302325919929dda3fecad0939ef59772d9d3625460353d2790f4d1338
BLAKE2b-256 checksum
How to use checksums
43c4cc0aa60228e29c5e0516c4d71896412c55b7c115bb0d357ecc7276a4108f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.19

Release files / python_aoc-0.1.6-py3-none-any.whl

Download URL python_aoc-0.1.6-py3-none-any.whl
Size 10.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5e2114caeb02f1ed2acef115cfa0f160a1eb1089a9c51b16bb21536a15f9db06
BLAKE2b-256 checksum
How to use checksums
c17000369c6bfada5647c71636b62c75ede88fa6c32a0a75bbbf8bcffbca1fa9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.19

Security for python-aoc 0.1.6

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page