Skip to main content

advent-of-code-sample

This repository provides a working example plugin structure for using the aoc runner script provided by advent-of-code-data. You could fork this repo and edit it, or just write your own plugin manually.

The aoc runner allows you to easily verify your Advent of Code solutions against multiple datasets, or verify other user's code against your own dataset.

$ cat ~/.config/aocd/tokens.json  # create this file with some auth tokens
{
    "github": "53616c7465645f5f0775...",
    "google": "53616c7465645f5f7238...",
    "reddit": "53616c7465645f5ff7c8...",
    "twitter": "53616c7465645f5fa524..."
}
$ pip install ~/src/advent-of-code-sample  # install the directory which contains your advent-of-code solutions
...
$ pip install -q advent-of-code-wim  # can also install some other user's code if you want..?
...
$ aoc --years 2015 --days 3 4 11    # run it!
   0.25s   2015/3  - Perfectly Spherical Houses in a Vacuum            wim/github    ✔ part a: 2565                             ✔ part b: 2639
   0.11s   2015/3  - Perfectly Spherical Houses in a Vacuum            wim/google    ✔ part a: 2592                             ✔ part b: 2360
   0.12s   2015/3  - Perfectly Spherical Houses in a Vacuum            wim/reddit    ✔ part a: 2592                             ✔ part b: 2360
   0.12s   2015/3  - Perfectly Spherical Houses in a Vacuum            wim/twitter   ✔ part a: 2565                             ✔ part b: 2639
   0.12s   2015/3  - Perfectly Spherical Houses in a Vacuum     myusername/github    ✖ part a: 1234 (expected: 2565)            ✖ part b: 5678 (expected: 2639)
   0.12s   2015/3  - Perfectly Spherical Houses in a Vacuum     myusername/google    ✖ part a: 1234 (expected: 2592)            ✖ part b: 5678 (expected: 2360)
   0.11s   2015/3  - Perfectly Spherical Houses in a Vacuum     myusername/reddit    ✖ part a: 1234 (expected: 2592)            ✖ part b: 5678 (expected: 2360)
   0.11s   2015/3  - Perfectly Spherical Houses in a Vacuum     myusername/twitter   ✖ part a: 1234 (expected: 2565)            ✖ part b: 5678 (expected: 2639)
   9.04s   2015/4  - The Ideal Stocking Stuffer                        wim/github    ✔ part a: 254575                           ✔ part b: 1038736
  25.43s   2015/4  - The Ideal Stocking Stuffer                        wim/google    ✔ part a: 117946                           ✔ part b: 3938038
  12.20s   2015/4  - The Ideal Stocking Stuffer                        wim/reddit    ✔ part a: 254575                           ✔ part b: 1038736
  47.67s   2015/4  - The Ideal Stocking Stuffer                        wim/twitter   ✔ part a: 282749                           ✔ part b: 9962624
   0.12s   2015/4  - The Ideal Stocking Stuffer                 myusername/github    ✖ part a: 1234 (expected: 254575)          ✖ part b: 5678 (expected: 1038736)
   0.12s   2015/4  - The Ideal Stocking Stuffer                 myusername/google    ✖ part a: 1234 (expected: 117946)          ✖ part b: 5678 (expected: 3938038)
   0.12s   2015/4  - The Ideal Stocking Stuffer                 myusername/reddit    ✖ part a: 1234 (expected: 254575)          ✖ part b: 5678 (expected: 1038736)
   0.12s   2015/4  - The Ideal Stocking Stuffer                 myusername/twitter   ✖ part a: 1234 (expected: 282749)          ✖ part b: 5678 (expected: 9962624)
   6.17s   2015/11 - Corporate Policy                                  wim/github    ✔ part a: vzbxxyzz                         ✔ part b: vzcaabcc
   6.26s   2015/11 - Corporate Policy                                  wim/google    ✔ part a: cqjxxyzz                         ✔ part b: cqkaabcc
   4.69s   2015/11 - Corporate Policy                                  wim/reddit    ✔ part a: hxbxxyzz                         ✔ part b: hxcaabcc
   5.75s   2015/11 - Corporate Policy                                  wim/twitter   ✔ part a: hxbxxyzz                         ✔ part b: hxcaabcc
   0.11s   2015/11 - Corporate Policy                           myusername/github    ✖ part a: 1234 (expected: vzbxxyzz)        ✖ part b: 5678 (expected: vzcaabcc)
   0.12s   2015/11 - Corporate Policy                           myusername/google    ✖ part a: 1234 (expected: cqjxxyzz)        ✖ part b: 5678 (expected: cqkaabcc)
   0.11s   2015/11 - Corporate Policy                           myusername/reddit    ✖ part a: 1234 (expected: hxbxxyzz)        ✖ part b: 5678 (expected: hxcaabcc)
   0.12s   2015/11 - Corporate Policy                           myusername/twitter   ✖ part a: 1234 (expected: hxbxxyzz)        ✖ part b: 5678 (expected: hxcaabcc)

How to hook into your code:

The aoc runner uses a Python packaging 'plugin' feature called entry points to locate and run your code. See https://entrypoints.readthedocs.io/ for more info about advertising an entry point from your code.

In your package, define your plugin's entry point in your Python package. The group name to use is "adventofcode.user".

Example for pyproject.toml

[project.entry-points."adventofcode.user"]
myusername = "mypackage:mysolve"

Example for older setup.py based packaging:

# setup.py
from setuptools import setup

setup(
    ...
    entry_points={"adventofcode.user": ["myusername = mypackage:mysolve"]},
)

Change mypackage to whatever package or module name is used to import your stuff. The name mysolve should resolve to a callable in your package's namespace which accepts three named arguments year, day, data (any order ok) and returns two values:

def mysolve(year, day, data):
    ...
    return part_a_answer, part_b_answer

Inside the entry point you can do whatever you need in order to delegate to your code. For example, write out data to a scratch file then run a script, or import a function and just pass in the data directly as an argument. The only requirement is that this entry point should return a tuple of two values, with the answers for that day's puzzle - the rest is up to you.

Metadata

Release files for advent-of-code-sample 0.2

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

Source distribution (sdist)

Source distribution for advent-of-code-sample 0.2
File Size Uploaded Provenance Actions
advent_of_code_sample-0.2.tar.gz 4.1 kB Without provenance Details for advent_of_code_sample-0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for advent-of-code-sample 0.2
File Interpreter ABI Platform Actions
advent_of_code_sample-0.2-py3-none-any.whl Python 3 none any Details for advent_of_code_sample-0.2-py3-none-any.whl

Total release size: 9.1 kB

Release files / advent_of_code_sample-0.2.tar.gz

Download URL advent_of_code_sample-0.2.tar.gz
Size 4.1 kB
Tags Source
SHA-256 checksum
How to use checksums
865c16c453d726d87ab232bfb2d0de43f1a4efb6f180e43efd921cc992cf7d4d
BLAKE2b-256 checksum
How to use checksums
5d41c69f8919a6e980c559600836c90c4f29e587766026f22f224f0a65bea366
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.2

Release files / advent_of_code_sample-0.2-py3-none-any.whl

Download URL advent_of_code_sample-0.2-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
796f4263f6f87c08812933b74dc2cdda48efb83a45ba17f3b3614a1edafd5356
BLAKE2b-256 checksum
How to use checksums
690d33fe43bb5eb32e5cc6bc0e1b1e5f5be898c1ceb6de9c9a008ada66a6557f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.2

Security for advent-of-code-sample 0.2

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.2 This release

2 release files 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