This version adds support for running solutions against multiple example inputs
in both iex and in test modules. Since this requires changing the naming scheme
of example files, users who wrote tests that rely on example input must run
mix aoc.get
to fetch the examples for each day that uses example input in
tests.
- Make
mix aoc.get
fetch and store each example input, not just the first (this is useful when several example are available or when part 2 supplies additional examples) - Update
example_path/1
andexample_string/1
to accept an:n
option to retrieve the n-th example (0-based). - Add
AOC.IEx.list_examples/1
to show the available examples. - Update
AOC.Case
so thatexample_path/1
andexample_string/1
optionally accept the index of the example to use. - Remove warning on freshly generated aoc code about unused input.
- Make
mix aoc.gen
useexample_string()
instead ofexample_input()
, which doesn't exist.
This update makes the "puzzle input" method introduced in 3.0.0 the only way to write solution modules. The old, "helper function" method is no longer supported.
The helper function method worked as follows:
aoc year, day do
def p1, do: input_string() |> # Solve puzzle
end
The puzzle input method works as follows:
aoc year, day do
def p1(input), do: input |> # solve puzzle
end
Input is provided through the use of the helpers in AOC.IEx
.
The input method is preferred as it makes it easier to test your solution using different inputs without the need to modify any code. It also makes it significantly easier to write tests for your solution module.
Users who wish to keep using the helper method are advised to stick to version 3 of Advent of Code Utils.
This update adds optional support for generating unit test modules for your solution modules. You can now write:
aoc_test year, day do
end
Which will create an ExUnit.Case
which tests your solution module. The
generated case will automatically call the doctests of your solution module.
mix aoc.gen
can now also generate this test code and add doctests to your
solution module.
- Introduce
AOC.aoc_test/4
,AOC.Case
. - Update
mix aoc.gen
to generate unit test files - Remove
example_path/1
,input_path/1
,example_string/1
,input_string/1
,example_stream/1
,input_stream/1
fromAOC
module. - Remove
example_stream/1
,input_stream/1
fromAOC.IEx
. - Rename
fetch_example
configuration tofetch_example?
for consistency.
- Optionally show the elapsed time when calling a
p1
,p2
,p1i
,p1e
,p2i
andp2e
. This is done when thetime_calls?
configuration option is set to true.
AOC.IEx.mod/1
now callsCode.ensure_loaded!/1
to ensure the target module is loaded. This is done to prevent issues wherep1e
andp1i
complain that the target module does not exist.
input_stream
,input_string
,example_stream
andexample_string
now only trim trailing newlines, not significant whitespace.
- Timezone support: the project now accepts a
time_zone
configuration setting which can be used to specify the time zone used by the input fetcher and iex helpers. This can be set to a time zone string, to:aoc
or to:local
(the default).:local
uses the system time, as before, while:aoc
uses the advent of code time zone (i.e. EST).
AOC.IEx
has been reworked.- All functions accept an
opts
keyword list used to specify year or day when needed. p1
andp2
now accept puzzle input as an argument, making it easier to switch between different inputs or examples.- Introduce
p1e
,p1i
,p2e
andp2i
to facilitate callingp1
orp2
with example or puzzle input. - Introduce wrapper functions
example_path/1
,input_path/1
,example_string/1
,input_string/1
,example_stream/1
andinput_stream/1
to facilitate experimentation inside iex.
- All functions accept an
- Update
AOC
documentation to reflect to new workflow. - Update
mix aoc.gen
to generate a template more suited to new workflow.
- Pass user agent when using
mix aoc.get
- Update ex_doc, add typespecs to public functions.
input_string
andexample_string
now both callString.trim_trailing/1
on the returned string.
- Download example input when using
mix aoc.get
. - Add
example_*
functions toAOC
module.
- Make
input_*
functions public (def
instead ofdefp
) to facilitate debugging.
- Initial stable release