- Language: Elixir 1.17.3 (Erlang/OTP 27)
- Editor: VS Code, with ElixirLS extension
- Package control: hexpm
- OS: Ubuntu 22.04 (WSL)
- Download asdf version manager according to docs
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.1
- Install asdf by adding to
.bashrc
(note single- and double-quotes)
echo '. "$HOME/.asdf/asdf.sh"' >> ~/.bashrc
(Optional: add auto-completions)
echo '. "$HOME/.asdf/completions/asdf.bash"' >> ~/.bashrc
\ - Source the modified .bashrc - or - re-open shell
source ~/.bashrc
- Install Erlang and Elixir plugins with asdf
asdf plugin add erlang
asdf plugin add elixir
- Install Erlang dependencies, according to plugin README
sudo apt-get -y install build-essential autoconf m4 libncurses5-dev libwxgtk3.0-gtk3-dev libwxgtk-webview3.0-gtk3-dev libgl1-mesa-dev libglu1-mesa-dev libpng-dev libssh-dev unixodbc-dev xsltproc fop libxml2-utils libncurses-dev openjdk-11-jdk
- Install latest version of Erlang
asdf latest erlang
asdf install erlang 27.1.2
- Install latest version of Elixir (compatible with Erlang version)
asdf latest elixir
asdf install elixir 1.17.3-otp-27
- Create a new project in current dir
mix new .
- Save puzzle input of the day as
input
in root of repo - Prepare files per day:
./setup_day.sh d
, replaced
with current day of month - Write solution in
run_p
andrun_q
. Part 1 = p, Part 2 = q - Compile project and load in interactive Elixir shell
iex -S mix
- Run day d part y in iex:
Aoc2024.run_day(d, :y)
. Part defaults to :p (1).
E.g:Aoc2024.run_day(1)
- run day 1, part 1Aoc2024.run_day(3, :p)
- run day 3, part 1Aoc2024.run_day(4, :q)
- run day 4, part 2
- For example input, manually save it in
lib/inputs/example/
as:day{x}.txt
for days (d=) 10-25day0{x}.txt
for days (d=) 1-9
- To run with example input for day d, part y in iex, add
:example
atom to args:Aoc2024.run_day(x, :y, :example)
Part / Example aliases
Equivalent forms of Aoc2024.run_day/3
for day d:
Aoc2024.run_day(d, :p)
<=>Aoc2024.p(d)
Aoc2024.run_day(d, :q)
<=>Aoc2024.q(d)
Aoc2024.run_day(d, :p, :example)
<=>Aoc2024.px(d)
Aoc2024.run_day(d, :q, :example)
<=>Aoc2024.qx(d)
If available in Hex, the package can be installed
by adding aoc2024
to your list of dependencies in mix.exs
:
def deps do
[
{:aoc2024, "~> 0.1.0"}
]
end
Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/aoc2024.