Skip to main content

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

Project description

Advebt 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.0.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.0-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: aoc_input_fetcher-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 6fc589846e9d19ded951df437103a8886b2c41dbca3dc1785008a886517521b6
MD5 63fb29968083aab17894e70eeec68a2c
BLAKE2b-256 e5e4d7788de6b362da61339bc011c098d02c73dc2912d977914076328886acde

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aoc_input_fetcher-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0001b03fe2ccad4db8258e18650966bb6016c98ac17225f43ce08033b17b3ec6
MD5 e6ca7039aa6f8d28bc3cfbe44d6fcf47
BLAKE2b-256 30cb3448efb0e51fc1108798389e2470562222b5a909ccb2be065e56027838a1

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