Utility library for Advent of Code (https://adventofcode.com)
Find a file
2025-10-13 19:50:02 +02:00
aocutil Add abs 2025-10-13 19:50:02 +02:00
.gitignore Initialize aocutils 2022-12-04 13:50:57 +01:00
.python-version New uv based project and rewritten tool 2025-09-26 15:14:29 +02:00
pyproject.toml Add aocload 2025-09-29 17:06:26 +02:00
README.md New uv based project and rewritten tool 2025-09-26 15:14:29 +02:00
uv.lock Add aocload 2025-09-29 17:06:26 +02:00

AoC Utils

This small library can be used for the yearly Advent of Code (https://adventofcode.com) challenge. It automates the retrieval of puzzle input and submission.

Installation

aocutil is published on PyPi and can be installed from there.

Usage

from aocutil import Aoc

# Initialize for year 2022, day 1
#
# Note that aocutil needs a session id to work. It is read from
# `${HOME}/.config/aocutil/session_id`.
aoc = Aoc(year=2022, day=1)

# Retrieve the day's input
puzzle = aoc.input()

# Submit the solution. aocutil will automatically
# try to figure out the correct puzzle to submit the
# answer to.
# The result is printed to stdout.
aoc.submit("solution")

Retrieving the Session ID

A user in Advent of Code submissions and input retrieval is determined by a session id stored in a cookie in the user's browser. For this library to work it needs a users session id. The session id can be found by opening your browsers developer tools and looking for a cookie named session.

Store the session id in ${HOME}/.config/aocutil/session_id. Everyone who gets hold of your session id can impersonate you, so keep this secret.