Skip to content

Advent of Code 2024 edition (Elixir)

Notifications You must be signed in to change notification settings

martinfalke/aoc2024

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⭐ Advent of Code 2024 🎄

AoC 2024 webpage


🛠 Tools

  • Language: Elixir 1.17.3 (Erlang/OTP 27)
  • Editor: VS Code, with ElixirLS extension
  • Package control: hexpm
  • OS: Ubuntu 22.04 (WSL)

🏗 Setup

  1. Download asdf version manager according to docs
    git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.1
  2. 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\
  3. Source the modified .bashrc - or - re-open shell
    source ~/.bashrc
  4. Install Erlang and Elixir plugins with asdf
    asdf plugin add erlang
    asdf plugin add elixir
  5. 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
  6. Install latest version of Erlang
    asdf latest erlang
    asdf install erlang 27.1.2
  7. Install latest version of Elixir (compatible with Erlang version)
    asdf latest elixir
    asdf install elixir 1.17.3-otp-27
  8. Create a new project in current dir mix new .

Daily repeat steps

  1. Save puzzle input of the day as input in root of repo
  2. Prepare files per day: ./setup_day.sh d, replace d with current day of month
  3. Write solution in run_p and run_q. Part 1 = p, Part 2 = q
  4. Compile project and load in interactive Elixir shell iex -S mix
  5. 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 1
    • Aoc2024.run_day(3, :p) - run day 3, part 1
    • Aoc2024.run_day(4, :q) - run day 4, part 2
  6. For example input, manually save it in lib/inputs/example/ as:
    • day{x}.txt for days (d=) 10-25
    • day0{x}.txt for days (d=) 1-9
  7. 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)

Auto-generated by mix new

Installation

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.

About

Advent of Code 2024 edition (Elixir)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published