Skip to main content

A library for Advent of Code containing utilities to use while solving problems!

Project description

Advent of Code Module

A library for Advent of Code containing utilities to use while solving problems! If any issues or bugs are discovered, please submit an issue and I'll fix it!

Installation and basic use

To install, simply run the following command.

pip install aoc-mod

AOC Mod can be used interactively from the command line or as a library to import into your Advent of Code challenge solutions with Python.

You may follow the sections below to either utilize the command-line utility or see this example for using the library programmatically.

from aoc_mod.utilites import AOCMod

aoc_mod = AOCMod()

puzz_input = aoc_mod.get_puzzle_input({YEAR}, {DAY})
instructions = aoc_mod.get_puzzle_instructions({YEAR}, {DAY})

sol = do_the_solution_p1()

aoc_mod.submit_answer({YEAR}, {DAY}, 1, sol)

How to set the session ID environment variable

To grab puzzle instructions and input or submit an answer, you'll need the to store session ID from your login to Advent of Code as an environment variable.

export SESSION_ID=cbef2304aaa12390fbc7absc3892 

Usage aoc-mod

usage: aoc-mod [-h] [--debug] {setup,submit} ...

positional arguments:
  {setup,submit}
    setup         Initiate the setup of the files for AoC.
    submit        Initiate a submission of the answer for an AoC problem.

options:
  -h, --help      show this help message and exit
  --debug         Enable debug print statements.

Usage aoc-mod setup

usage: aoc-mod setup [-h] [-d YEAR:DAY]

options:
  -h, --help            show this help message and exit
  -d YEAR:DAY, --date YEAR:DAY
                        Enter the year and day of the Advent of Code challenge you would like.

Usage aoc-mod submit

usage: aoc-mod submit [-h] -a ANSWER -l {1,2} -d YEAR:DAY

options:
  -h, --help            show this help message and exit
  -a ANSWER, --answer ANSWER
                        Answer to submit.
  -l {1,2}, --level {1,2}
                        Part A = 1; Part B = 2
  -d YEAR:DAY, --date YEAR:DAY
                        Enter the year and day of the Advent of Code challenge you would like.

Class: AOCMod

init(self)

Initialize the AOCMod class and set up the current time and authentication variables.

set_auth_variables(self)

Set the authentication variables from environment variables.

get_current_date(self)

Get the current local time.

Returns:

  • time.struct_time: The current local time.

verify_correct_date(self, year: int, month: int, day: int)

Verify if the provided date is valid for Advent of Code.

Args:

  • year (int): The year to verify.
  • month (int): The month to verify.
  • day (int): The day to verify.

Returns:

  • bool: True if the date is valid, False otherwise.

Constants

URL_PUZZLE_MAIN

The main URL template for Advent of Code puzzles.

URL_PUZZLE_INPUT

The URL template for Advent of Code puzzle input.

URL_PUZZLE_ANSWER

The URL template for Advent of Code puzzle answer submission.

Logging

LOGGER

A logger instance for the module.

Dependencies

  • os
  • logging
  • time
  • requests
  • markdownify
  • bs4.BeautifulSoup

Contributing

If you feel that you have new features to contribute, don't hesitate to submit a pull request!

How to build aoc-mod

$(realpath `which python3`) -m venv .venv
source .venv/bin/activate

pip install -e .[build,test]

python -m build

How to test aoc-mod

After following the build steps, run pytest.

pytest -vv

Project details


Download files

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

Source Distribution

aoc_mod-0.1.5.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aoc_mod-0.1.5-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file aoc_mod-0.1.5.tar.gz.

File metadata

  • Download URL: aoc_mod-0.1.5.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for aoc_mod-0.1.5.tar.gz
Algorithm Hash digest
SHA256 9961adff5795cf428bc8945ba0eb4d57cc3520aaff0b294fd77ea11f8d77e825
MD5 886154e41c9972435650668711306337
BLAKE2b-256 8c582189ec5db199e9498b3f33f789cb53c42ee76086b50c31492e34bd43ece9

See more details on using hashes here.

Provenance

The following attestation bundles were made for aoc_mod-0.1.5.tar.gz:

Publisher: build_wheel.yml on cosmos1255/aoc_mod

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aoc_mod-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: aoc_mod-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for aoc_mod-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 cc83f39d7eef0e9cc81a1ca8b669c9e1612923e18460e13cc2a53848edab29d6
MD5 4c2701685b50921afa0709c0d8a69946
BLAKE2b-256 4c153b0fa8b93d29445694a25657b3901c1f3a633728b6afd3135035b6568ea2

See more details on using hashes here.

Provenance

The following attestation bundles were made for aoc_mod-0.1.5-py3-none-any.whl:

Publisher: build_wheel.yml on cosmos1255/aoc_mod

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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