Utility library for Advent of Code (https://adventofcode.com)
| aocutil | ||
| .gitignore | ||
| .python-version | ||
| pyproject.toml | ||
| README.md | ||
| uv.lock | ||
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.