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.

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


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.3.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

advent_of_code_data-0.3-py2.py3-none-any.whl (8.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file advent-of-code-data-0.3.tar.gz.

File metadata

File hashes

Hashes for advent-of-code-data-0.3.tar.gz
Algorithm Hash digest
SHA256 d6cb5126c4b84f97c65e1c1e43bed4c8b29e262f15f260fc949bb7543012c62f
MD5 8307677f63e0eabebe2eedf4231b64c0
BLAKE2b-256 07d291f78eb4f7a66132dce91f0e962d96268566da470ea07f19498bc0b4f846

See more details on using hashes here.

File details

Details for the file advent_of_code_data-0.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for advent_of_code_data-0.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 347087dd55c82edd3f4c947b15a89f669bfa09e60bd74f1c6886b9b24d4f5bf7
MD5 0c0ac1d68349415cecd2645441c41fe9
BLAKE2b-256 211aba860e97f38199a89634fc01106624ebc5f74944b97d6023c72d9b3fa3ac

See more details on using hashes here.

Supported by

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