AdventOfCodeInputReader
AdventOfCodeInputReader
A python package to get the input for Advent Of Code challenges as a list
Contents
Getting Started
- Installation using pip (Python Package Index):
$ pip install AdventOfCodeInputReader
Using AdventOfCodeInputReader
Import and Initialise
The AdventOfCode class (defined in init.py) has one mandatory parameter (session_id) and two optional parameters (year and day). To get session_id, you need to log into Advent of Code and retreieve the session id from your browser cookies. Your session id is required as the challenge input is different for each user.
from AdventOfCodeInputReader import AdventOfCodeInputReader
# Initialize with only session_id
reader = AdventOfCodeInputReader("your_session_id")
# Initialize with session_id and year only
reader = AdventOfCodeInputReader("your_session_id",2021)
# Initialize with session_id and year and day
reader = AdventOfCodeInputReader("your_session_id",2021,1)
Methods
The AdventOfCode class has three methods: get_input(), get_input_by_day(), get_input_by_year_and_day(). All three methods will return a list of strings, with each line of the input as an element in the list.
get_input()
The get_input(day=None, year=None) method has two optional parameters, day and year. If you have specified the values for day and year at initalization, you can use this method without any arguments. If you have included values for day and year at initization but included day and year arguments for get_input(), the method will override and use the arguments provided in get_input() for this specific run only. It will not update the class value.
# Using get_input() with year and day specified at initalization
reader = AdventOfCodeInputReader("your_session_id",2021,1)
input = reader.get_input()
# Using get_input() with only year specified at initalization
reader = AdventOfCodeInputReader("your_session_id",2021)
input = reader.get_input(day=1)
# Using get_input() without year and day specified at initalization
reader = AdventOfCodeInputReader("your_session_id")
input = reader.get_input(day=1,year=2021)
This method returns a list of strings, with each line of the input as an element in the list.
If the input from Advent of Code looks like:
line 1
line 2
line 3
The method will return:
["line 1", "line 2", "line 3"]
get_input_by_day()
The get_input_by_day(day) method requires the year to be declared at initialization. If you have included value for day at initization but included day argument for get_input_by_day(), the method will override and use the argument provided in get_input_by_day() for this specific run only. It will not update the class value.
reader = AdventOfCodeInputReader("your_session_id",2021)
input = reader.get_input_by_day(1)
This method returns a list of strings, with each line of the input as an element in the list.
If the input from Advent of Code looks like:
line 1
line 2
line 3
The method will return:
["line 1", "line 2", "line 3"]
get_input_by_year_and_day()
The get_input_by_year_and_day(year, day) method requires the year and day arguments to be specified when using the method. If you have included value for year or day at initization, the year and day arguments provided will be used instead of the values specified at initalization for this specific run only. It will not update the class value.
reader = AdventOfCodeInputReader("your_session_id")
input = reader.get_input_by_year_and_day(year=2021,day=1)
This method returns a list of strings, with each line of the input as an element in the list.
If the input from Advent of Code looks like:
line 1
line 2
line 3
The method will return:
["line 1", "line 2", "line 3"]
Metadata
Release files for AdventOfCodeInputReader 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| AdventOfCodeInputReader-0.0.3.tar.gz | 4.0 kB | Without provenance | Details |
Release files / AdventOfCodeInputReader-0.0.3.tar.gz
| Download URL | AdventOfCodeInputReader-0.0.3.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a9f19b79e74b6837383c19ed491ecbb991d06119537f94c29e20b0c39eda87a0
|
|
BLAKE2b-256 checksum How to use checksums |
5e4fc75c5d80207e66cfebc6a0debc158d2624a3a5f0a42ca4af2e104e70005a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.5
|
Security for AdventOfCodeInputReader 0.0.3
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.