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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for aoc_input_fetcher-0.1.2.tar.gz
Algorithm Hash digest
SHA256 86d13ec3d60e2d9ffbcce95a18e3621b98872914e66605c5b3c181cc0278d775
MD5 955c313faef733d274f200ceefe62942
BLAKE2b-256 295387fa88e92d6cbb6788274023f15d42d233a9257b9334a27c9f5ea11638a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for aoc_input_fetcher-0.1.2.tar.gz:

Publisher: python-publish.yml on Mourud/aoc-input-fetcher

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for aoc_input_fetcher-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a55b9256654b11a788513c5777b858797b68df5d3beb366fd5081514a92ce028
MD5 79a41cce940b37119285e7583104a684
BLAKE2b-256 cea25eed345cfc6dc608e0d5281aa3eace48813d45de88957520ceb58eb27770

See more details on using hashes here.

Provenance

The following attestation bundles were made for aoc_input_fetcher-0.1.2-py3-none-any.whl:

Publisher: python-publish.yml on Mourud/aoc-input-fetcher

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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