Get your puzzle data with a single import
Project description
Get your puzzle data with a single import statement:
from aocd import data
Might be useful for lazy Pythonistas and speedhackers.
Note: Please use version 0.3+ of this library. It memoizes successful requests client side and rate-limits the get_data function, as requested by the AoC author. Thanks!
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 text file in your home directory (use the filename ~/.aocdrc).
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 won’t import the same module twice, so if you want to get data for multiple problems from within the same interpreter session then you should be using the get_data function directly.
>>> 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
Release history Release notifications | RSS feed
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
Hashes for advent-of-code-data-0.3.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9886a9b9d6bffbd688122e9e9cfe79cf15ce08d3254b12490792f8d87eab2ed1 |
|
MD5 | 8d6e7b503dfc474d6828bc076314217c |
|
BLAKE2b-256 | fd74d1727ad479ce5373c03e9a15a9dc4810f9cc63ae6bbd61b04ab619e92115 |
Hashes for advent_of_code_data-0.3.4-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e8254fc2cf92337f922c18f369ed4f2be9bee7d402324a4cd18ed394371c9fe |
|
MD5 | 2d90862a2e93dc1bc20c91cd920e9c64 |
|
BLAKE2b-256 | 40dd33534dc8eaaa8c3fc15154575d855e7dc9e182b193e518308a73794f4e97 |