Skip to main content

Get your puzzle data with a single import

Project description

pyversions pypi womm

Get your puzzle data with a single import statement:

from aocd import data

Might be useful for lazy Pythonistas and speedhackers.

Setup Guide

Install with pip

pip install advent-of-code-data

Puzzle inputs differ by user. So export your session ID, for example:

export AOC_SESSION=cafef00db01dfaceba5eba11deadbeef

This is a cookie which is set when you login to AoC. You can find it with your browser inspector. If you’re hacking on AoC at all you probably already know these kind of tricks, but if you need help with that part then you can look here.

Note: If you don’t like the env var, you could also put into a file my_session.txt in your working directory.

How does it work?

It will automatically get today’s data at import time, if used within the interactive interpreter. Otherwise, the date is found by introspection of the path and file name from which aocd module was imported.

This means your filenames should be something sensible. The examples below should all parse correctly:

q03.py
xmas_problem_2016_25b_dawg.py
~/src/aoc/2015/p8.py

A filename like problem_one.py will break shit, so don’t do that. If you don’t like weird frame hacks, just use the aocd.get_data() function instead and have a nice day!

Please be aware that Python will not import the same module twice, so if you need to get puzzle for multiple problems from within the same interpreter session then you will need to use the function directly rather than using the import-time magic.

>>> from aocd import get_data
>>> get_data(day=2)
'UULDRRRDDLRLURUUURUURDRUURRDRRURUD...
>>> get_data(day=24, year=2015)
'1\n2\n3\n7\n11\n13\n17\n19\n23\n31...

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

advent-of-code-data-0.1.tar.gz (4.1 kB view hashes)

Uploaded Source

Built Distribution

advent_of_code_data-0.1-py2.py3-none-any.whl (7.3 kB view hashes)

Uploaded Python 2 Python 3

Supported by

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