Skip to main content

A useful tool for getting the input automatically for Advent of Code, given you follow the file structure

Project description

Advent of Code Input Fetcher

aoc_input_fetcher is a Python package that automates fetching input files for Advent of Code challenges, assuming a specific file structure for your project.


Features

  • Automatically fetches input for Advent of Code puzzles from file name and directory sturcture.
  • Supports user-provided session cookies for authentication.
  • Simplifies managing input files for each day of the challenge.
  • Easy to integrate with your existing workflow.

Installation

You can install the package via pip:

pip install aoc_input_fetcher

Usage

Setup

To use aoc_input_fetcher, you need to: 1. Log in to Advent of Code and copy your session cookie. 2. Save the cookie to a .env file in the following format:

AOC_COOKIE=<your_session_cookie>

File Structure

The package expects the following file structure for your Advent of Code project:

aoc/2024/
├── day1.py
├── day5.py
├── inputs/
│   ├── day1.txt
│   └── day5.txt

Fetch Input

Example of fetching input for Day 1:

from aoc_input_fetcher import fetch_input

input = fetch_input(__input__)

This will download the input for Day 1 and save it to inputs/day1.txt in the project root. The input is returned as a string as well.

Demo

Here’s a quick demo of how to use the package:

from aoc_input_fetcher import fetch_input

from input_fetcher import fetch_input

def main():
    input = fetch_input(__file__)
    if input is None:
        return
    formatted_input = format_input(input)
    print(part1(formatted_input))
    print(part2(formatted_input))
main()

For a detailed look at how I have been using it check out my Advent of Code repository

Requirements

This package requires: • Python 3.6 or newer • requests library (automatically installed with the package) • python-dotenv library (automatically installed with the package)

Contributing

Contributions are welcome! If you have ideas for improvements or find bugs: 1. Fork the repository. 2. Make your changes. 3. Submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Support

If you encounter issues or have questions, feel free to open an issue on GitHub.

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

aoc_input_fetcher-0.1.1.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

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

aoc_input_fetcher-0.1.1-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file aoc_input_fetcher-0.1.1.tar.gz.

File metadata

  • Download URL: aoc_input_fetcher-0.1.1.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.2

File hashes

Hashes for aoc_input_fetcher-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6d30427a1a0ac22d6931c6bf445e4008420a9669ef9e032cf01ededb00a3e65d
MD5 e5abb88b697cadcb1fb7fd6552c9214d
BLAKE2b-256 0de1ff3d48ecdeb02d8b1ffd9da2e72d3583ec4a7d122f15ead10ab96081ef6f

See more details on using hashes here.

File details

Details for the file aoc_input_fetcher-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for aoc_input_fetcher-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bb97d48ca6f479ba6a5856149d27759d9ec60a717f4814210a815609444c4a08
MD5 50e35e45e01b3866aaf90e980867ac42
BLAKE2b-256 4e4a25e9a3fc85de41818901233c599e539c82576bc4f57dccd941d2d8747654

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