philipdouglas / Advent-Of-Code

Access your advent of code inputs, right from elixir!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Advent of Code Helper Build Status codecov Hex.pm

This elixir package allows you to quickly grab inputs for advent of code puzzles, and not have to worry about manually pasting them in! After you've got a puzzle input for the first time, the result is stored on disk so every subsequent request bypasses the need to download it from the server again.

Usage

There are only two functions you need to use this module:

AdventOfCodeHelper.get_input(year,day) # Specify year and day for puzzle

AdventOfCodeHelper.get_input(day) # Automatically gets puzzle from most recent year

Both of these functions will simply return a tuple {:ok, value} if they succeed, where value is the puzzle input in the form of a BitString, or {:fail, message} if there was something wrong.

There are two configuration directives that are also needed to make this package work correctly. Simply add the following to your config/config.exs

config :advent_of_code_helper,
session: "<session string>",
cache_dir: ".cache/" # this is a sensible default, but feel free to put it wherever you have write access

The session string will need to be taken from adventofcode.com, it will be under cookies as session. You can extract the value using the inspector in your browser of choice.

Installation

This package can be installed by adding advent_of_code_helper to your list of dependencies in mix.exs:

def deps do
  [
    {:advent_of_code_helper, "~> 0.1.0"}
  ]
end

About

Access your advent of code inputs, right from elixir!

License:MIT License


Languages

Language:Elixir 100.0%