Observed since 20 Oct, 20:01 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
advent-tools
Cool set of tools for working with Advent of Code challenges
Python interface to conveniently download and interact with advent data with a high-level-wrapper.
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
First we need to get the session cookie (🍪), in order to do that
Application tab, then to Cookiessession cookie value

AOC_SESSION=<session-cookie-value> environment variable (make sure terminal restart doesn't reset the value).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.
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)
Download counts and popularity will appear here as the collector receives them.
| Package / target | Requirement | Relationship |
|---|---|---|
platformdirsEnvironment{
"extras": "",
"marker": null,
"requires_python": ">=3.13",
"evaluation": "NOT_EVALUATED"
} | platformdirs>=4.3.6 | runtime |
python-dotenvEnvironment{
"extras": "",
"marker": null,
"requires_python": ">=3.13",
"evaluation": "NOT_EVALUATED"
} | python-dotenv>=1.0.1 | runtime |
requestsEnvironment{
"extras": "",
"marker": null,
"requires_python": ">=3.13",
"evaluation": "NOT_EVALUATED"
} | requests>=2.32.3 | runtime |
bdist_wheel · 14.18 KB · Python py3
sdist · 365.55 KB · Python source
Observed since 20 Oct, 20:01 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package_version:5caffc485b1ef44e6acfdb908fed572b1b8881fefbb01347ab6976dde2875c5c