View Source mix aoc.get (Advent of Code Utils v4.0.1)

Fetch the input and example input of the AOC challenge for a given day / year.

This mix task fetches the input and example input for the advent of code challenge of a specific day. The day and year of the challenge can be passed as command-line arguments or be set in the advent_of_code_utils application configuration. When neither is present, the current date is used.

By default, this task stores the fetched input data in input/<year>_<day>.txt. The fetched example is stored in input/<year>_<day>_example.txt. If a file already exists, the matching input is not fetched. The destination paths can be modified by setting the value of :input_path or :example_path in the advent_of_code_utils application configuration. These values should be set to a string which may contain :year and :day. These values will be replaced by the day and year of which the input is fetched.

For instance, the following configuration will store the fetched input data in my_input/<year>/<day>.input:

config :advent_of_code_utils, :input_path, "my_input/:year/:day.input"

In order to fetch your input, this task needs your advent of code session cookie. This can be obtained by investigating your cookies after logging in on the advent of code website. The cookie can be stored inside your config/config.exs file (e.g. config, :advent_of_code_utils, :session, "<your cookie here>") or it can be passed as a command-line argument. If no cookie is present, the input cannot be fetched.

Example input

The example input of a given day is fetched by parsing the challenge webpage of a given day and returning the first code example found on that page. This is generally the example input of that day. As this method is not foolproof, it is sometimes necessary to modify the example file by hand.

If you do not wish to fetch example input, you can pass the --no-example flag to this task, or you can set fetch_example? to false in the advent_of_code_utils application configuration.


Application environment

The following application configuration parameters can modify the behaviour of this task:

  • session: Advent of code sessions cookie.
  • day: Specify the day. Defaults to the current day.
  • year: Specify the year. Defaults to the current year.
  • time_zone: Specify the time-zone used to determine the local time. Defaults to the time zone of your computer. Please refer to the README for additional information.
  • input_path: Determines where the input file is stored. Defaults to "input/:year_:day.txt"
  • example_path: Determines where the example input is stored. Defaults to "input/:year_:day_example.txt"

Command-line arguments

The options below take precedence over values defined in the application configuration.

  • -s or --session: Specify the session cookie.
  • -d or --day: Specify the day.
  • -y or --year: Specify the year.
  • --no-example: Do not fetch example input
  • --example: Fetch example input