Skip to main content

aocpy - Advent of Code Automation Tool

PyPI version shields.io

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

Installation

Install via pip: pip install aocpy

Usage

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:

<day_number>/
  solution.py
  input.txt
# 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 solution.py

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

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

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
    <1234mycookie>
    
  • Environment variable:

    • $ export AOC_SESSION_COOKIE=<1234mycookie>
  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. adventofcode.com/2018/day/1/input
  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>

Metadata

Release files for aocpy 0.0.1

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

Built distribution (wheel)

Table of built distributions (wheels) for aocpy 0.0.1
File Interpreter ABI Platform Actions
aocpy-0.0.1-py2.py3-none-any.whl Python 2, Python 3 none any Details for aocpy-0.0.1-py2.py3-none-any.whl

Release files / aocpy-0.0.1-py2.py3-none-any.whl

Download URL aocpy-0.0.1-py2.py3-none-any.whl
Size 7.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
0456c9c725982e186c5a0266e892b60782d659bd8e73f794bbea8bcfd527798b
BLAKE2b-256 checksum
How to use checksums
c6dad4ea304b64dddaeffa826eff0a72c9082df5db0cd8cfa8fd188c44fdb9f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

Security for aocpy 0.0.1

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.

Release history Release notifications | RSS feed

This release

0.0.1 This release

1 release file No provenance

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