Skip to main content

Advent of Code Automation

Project description

aocpy - Advent of Code Automation Tool

PyPI version

Fetch input, submit answers and generate boilerplate files for solving Advent of Code puzzles :christmas_tree:


Install via pip: pip install aocpy


N.B Please see the Session Cookie Configuration section

Begin a Puzzle

begin fetches the puzzle input and generates boilerplate files with the following structure:

# fetch input and generate boilerplate for today's challenge
$ aocpy begin

# fetch input and generate boilerplate for a specific puzzle
$ aocpy begin -y 2017 -d 15
$ aocpy begin -d 15 # uses current puzzle year

Submit Puzzle Answers

# submit answer for level 1 of today's puzzle
$ aocpy submit "myanswer" 1

# submit answer for level 2 of today's puzzle
$ aocpy submit "myanswer2" 2

# submit answer for level 1 of a specific puzzle
$ aocpy submit "myanswer" 1 -y 2017 -d 15

# submit answer for level 2 of a specific puzzle
$ aocpy submit "myanswer2" 2 -y 2017 -d 15

Running Solutions

The solution template files include a small CLI to read input files.

$ cd <puzzle_day_dir>

# Default - run with aocpy generated input.txt file
$ python

# Run with example_input.txt if present
$ python -e

# Run with specified input file
$ python /path/to/my/file.txt

Session Cookie Configuration

AoC puzzle inputs differ by user, requiring a browser cookie to determine the current user. aocpy requires this cookie and can be supplied in several ways:

  • CLI -c/--session-cookie option (supported by all commands):

    • $ aocpy begin -c <1234mycookie>
  • Configuration file:

    • Paste the cookie into a file at ~/.config/aocpy/token
    # ~/.config/aocpy/token
  • Environment variable:

    • $ export AOC_SESSION_COOKIE=<1234mycookie>

Finding Your Session Cookie

  1. Open Advent of Code in a web browser and log in
  2. Open the browser's developer console
  • i.e. Right click -> Inspect or F12
  1. Select the Network tab
  2. Navigate to any puzzle input page i.e.
  3. Click on the request that shows up in the Network tab
  4. The cookie will be in the Request Headers section with the format Cookie: session=<1234mycookie>

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release. See tutorial on generating distribution archives.

Built Distribution

aocpy-0.0.1-py2.py3-none-any.whl (7.2 kB view hashes)

Uploaded py2 py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page