Skip to content

My solutions for the Advent of Code 2023 using Elixir.

Notifications You must be signed in to change notification settings

Peruibeloko/advent-of-code-2023

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Advent of Code 2023 (Elixir)

This repo contains my solutions for the 2023 Advent of Code. I took this opportunity to learn a new language I've been wanting to try out for some time, Elixir, a widely used Brazilian functional programming language.

What you'll find in here is mostly comprised of DSA, text manipulation and some other shenanigans.

Running

To run this project:

  1. Install Erlang/OTP 25 (direct link)
  2. Install Elixir (direct link)
  3. Clone this repo
  4. Run the day task

Tasks

mix day <day>.<part> [filename]

This command allows you to run the solution for the specific day and part, possibly using the provided filename as input.

If filename is absent, uses input.txt

Examples:

# Runs solution for Day 3 Part 2, using input.txt
mix day 3.2

# Runs solution for Day 4 Part 1, using test.txt
mix day 4.1 test

mix create <day>

Generates the following boilerplate for solving day:

advent_of_code/
├── (other solutions)
└── day_n/
    ├── part_1.ex
    ├── part_2.ex
    ├── input.txt
    └── test.txt

Each solution part is also initialized with some boilerplate code:

alias AdventOfCode.Utils

defmodule AdventOfCode.Day$day_number$.Part$part_number$ do
  def line_parser(line) do
    line
  end

  def run(file_name) do
    file_name
    |> Utils.parse_file(&line_parser/1)
  end
end

The $day_number$ and $part_number$ placeholders are replaced with the proper values during creation.