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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aoc_mod-0.1.4.tar.gz.
File metadata
- Download URL: aoc_mod-0.1.4.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
61c7beec93f5b4b95d7607c9f774f647311e0bab2293cccd0167953c2009a98f
|
|
| MD5 |
d064fd5049b4193f15e32826b55cca54
|
|
| BLAKE2b-256 |
49e5e0605ece12302467910e048665260fe3f62b4557c0320058e5641a394fc4
|
Provenance
The following attestation bundles were made for aoc_mod-0.1.4.tar.gz:
Publisher:
build_wheel.yml on cosmos1255/aoc_mod
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aoc_mod-0.1.4.tar.gz -
Subject digest:
61c7beec93f5b4b95d7607c9f774f647311e0bab2293cccd0167953c2009a98f - Sigstore transparency entry: 152635499
- Sigstore integration time:
-
Permalink:
cosmos1255/aoc_mod@232f01b3de73c437d6c39b4f34c6f0263ab4cbf6 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/cosmos1255
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build_wheel.yml@232f01b3de73c437d6c39b4f34c6f0263ab4cbf6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file aoc_mod-0.1.4-py3-none-any.whl.
File metadata
- Download URL: aoc_mod-0.1.4-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb2a9ee4069dde82a683180a3a8a090ff1297159a12d6ccfbfa54b1c238b7b63
|
|
| MD5 |
04855ff2f878c7412b85bb9ecababda3
|
|
| BLAKE2b-256 |
04b53964687fa02c30826537f295ebd539ee16b2339d8665b9e71b38b6118fcd
|
Provenance
The following attestation bundles were made for aoc_mod-0.1.4-py3-none-any.whl:
Publisher:
build_wheel.yml on cosmos1255/aoc_mod
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aoc_mod-0.1.4-py3-none-any.whl -
Subject digest:
cb2a9ee4069dde82a683180a3a8a090ff1297159a12d6ccfbfa54b1c238b7b63 - Sigstore transparency entry: 152635500
- Sigstore integration time:
-
Permalink:
cosmos1255/aoc_mod@232f01b3de73c437d6c39b4f34c6f0263ab4cbf6 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/cosmos1255
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build_wheel.yml@232f01b3de73c437d6c39b4f34c6f0263ab4cbf6 -
Trigger Event:
push
-
Statement type: