Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

advent-tools

Python interface to conveniently download and interact with advent data with a high-level-wrapper.

Installation

A Virtual Environment is strongly recommended to install the library

# Linux/macOS
python3 -m pip install -U advent-tools

# Windows
py -3 -m pip install -U advent-tools

Quickstart

First we need to get the session cookie (🍪), in order to do that

  1. Open your broswer's Devtools (Chrome / Firefox guide)
  2. Head on over to Application tab, then to Cookies
  3. Find and copy session cookie value "Steps to get session cookie"
  4. set AOC_SESSION=<session-cookie-value> environment variable (make sure terminal restart doesn't reset the value)
    OR
    Enter the following command in your terminal which will create an .env file storing your session cookie.
# Same for all Windows, Linux and macOS
echo AOC_SESSION=<session-cookie-value> > .env
# Make sure to replace <session-cookie-value> with your cookie value

Make sure version control system ignores your token container in case you are using one, cause your token is sensitive and can be used for log-ins.


Usage

year and day can be given as kwargs when subclassing advent.Advent or can be provided using it's __getitem__ behaviour like Advent[year:day]

from advent import Advent


class Solution(Advent, year=2020, day=3):
    def __init__(self, data: str) -> None:
        self.data = ...

    def part_1(self):
        ...

    def part_2(self):
        ...

Example 1:

from advent import Advent


class Solution(Advent, year=2022, day=2):
    PLAY = {"A": ["Z", "X", "Y"], "B": ["X", "Y", "Z"], "C": ["Y", "Z", "X"]}

    def __init__(self, data: str) -> None:
        self.data = [line.split() for line in data.splitlines()]

    def part_1(self):
        return sum(self.PLAY[oppo].index(me) * 3 + ord(me) - 87 for oppo, me in self.data)

    def part_2(self):
        return sum((fate := ord(res) - 88) * 3 + ord(self.PLAY[oppo][fate]) - 87 for oppo, res in self.data)

Example 2:

from heapq import nlargest
from advent import Advent

class Solution(Advent[2022:1]):
    def __init__(self, data: str) -> None:
        self.max, *self.top = nlargest(3, [sum(map(int, chunk.split())) for chunk in data.split("\n\n")])

    def part_1(self):
        return self.max

    def part_2(self):
        return self.max + sum(self.top)

Metadata

Release files for advent-tools 1.0.0b1

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-tools 1.0.0b1
File Size Uploaded Provenance
advent_tools-1.0.0b1.tar.gz 374.3 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for advent-tools 1.0.0b1
File Interpreter ABI Platform
advent_tools-1.0.0b1-py3-none-any.whl Python 3 none any Details

Total release size: 388.8 kB

Release files / advent_tools-1.0.0b1.tar.gz

Download URL advent_tools-1.0.0b1.tar.gz
Size 374.3 kB
Tags Source
SHA-256 checksum
How to use checksums
de2e8c3509a9bd73e4d516eb5a2b5bd618054860e5c880a90e30566a7d5e9879
BLAKE2b-256 checksum
How to use checksums
073578b6d5178c47b4e58244b221fc1139ba3aec631268441639a7e4dfced1c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.0.1 CPython/3.12.8

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 10, 2024.

Transparency log

Release files / advent_tools-1.0.0b1-py3-none-any.whl

Download URL advent_tools-1.0.0b1-py3-none-any.whl
Size 14.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3a46ea7517832a8226506d13be50eb587f651308e6525003a6f1285ef3af89f3
BLAKE2b-256 checksum
How to use checksums
c1fe4fc3249a280a8e473d28c176e08ef6245b6a6090235f1335cbb0dc7ad515
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.0.1 CPython/3.12.8

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 10, 2024.

Transparency log

Security for advent-tools 1.0.0b1

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for advent_tools-1.0.0b1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 10, 2024.

Transparency log

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.

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