Repo for doin' the puzzles with Elixir. Because Elixir is fun!
You can generate scaffolding for a day's solution by running mix day $puzzle_number $year
(e.g. mix day 12 2020
).
This will create a module for that day's puzzle and an accompanying test module. You'd run those like mix test test/aoc_2021/day01_test.exs
. The basic idea is that you implement each part in the appropriately named part_1
and part_2
functions in that day's module. These are called with the puzzle's input in the autogenerated tests.
Provide a valid session token in the root of the repo, in the .session_token
file, to automatically download the puzzle input file!
Run all the tests with mix test
.
You can add a tag above a long-running test so that it doesn't get run by default like so: @tag slow: true
Run all the tests, including ones that take a long time, with mix test --include slow
. Currently this takes about 5 minutes.
Also included is a mix
task which provides a convenient shortcut for running the tests for a particular day's puzzle. You can run it like this: mix test.aoc $day $year
(e.g. mix test.aoc 10 2021
). You can also run mix test.aoc.watch
to start mix test.watch
for the given day and year.
Benchmarks using benchee exist in the test dirs for some days. You run those like mix run test/aoc_2015/day05/day05_benchmarks.exs
. Benchmarking is cool!
A simple Github action is included, which runs the full test suite on each pushed commit.