Skip to content
forked from Atalanta/aocifetch

Fetch the input for Advent of Code puzzles

License

Notifications You must be signed in to change notification settings

aglet/aocifetch

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AoCifetch - fetch Advent of Code Input

Rationale

The input for Advent of Code puzzles is typically obtained by logging into the Advent of Code website and clicking on the input link for the puzzle in question. This produces the input needed for you to attempt to solve the puzzle.

While it’s not too painful to visit the site, click on the link, and download the input as a file (which can be used as a fixture), it would be even nicer to fetch the input with a single call. This allows east access to the input directly in a REPL or for subsequent processing when solving the puzzle. It also makes it easy for people to explore and use a shared solution without breaking the guidelines of not sharing the actual generated input.

AoCifetch is a simple library that does exactly this.

Usage

Add a dependency in deps.edn pointing to this repo at the appropriate tag or reference. For example:

     {:deps
      {atalanta/aocifetch
	{:git/url "https://github.com/Atalanta/aocifetch"
	 :git/tag "v0.1.0"}}}

Log in to the website, and locate your session cookie.

Set the envionment variable AOC_SESSION_COOKIE in the shell where you run your tests, code or REPL. This ensures the library has access the the session cookie to fetch the puzzle input.

The fetch-input function can be used to fetch the input:

(require '[aocifetch.core :as ifetch])

(def day1-input (ifetch/fetch-input "2024" "1"))

Development

Run specs with:

clj -M:spec -f d

There’s an integration test which validates the whole thing, without mocks. Set your AOC_SESSION_COOKIE and run”

clj -M:test -m aocifetch.integration-test

This will fetch the input for day 4 of Advent of Code 2022, which will contain a series of camp cleanup section assignments.

Status

Working, needs unhappy path tests.

Contributing

This project should move beyond vaporware pretty swiftly, as it scratches an immediate itch for me. However, contributions are welcome! Feel free to fork the repository, make improvements, and submit a pull request.

Ideas, feedback, feature requests, and other suggestions are also welcome via issues or discussions.

About

Fetch the input for Advent of Code puzzles

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Clojure 100.0%