2022-09-21 09:19:53 -04:00
|
|
|
defmodule AdventOfCode do
|
|
|
|
@moduledoc """
|
|
|
|
Solutions to the 2021 Advent of Code puzzles
|
|
|
|
"""
|
|
|
|
|
|
|
|
def solver(selector) do
|
|
|
|
[day, part] = String.split(selector, ".")
|
2022-09-21 09:19:53 -04:00
|
|
|
part_module(day, part)
|
2022-09-21 09:19:53 -04:00
|
|
|
end
|
2022-09-21 09:19:53 -04:00
|
|
|
|
|
|
|
def part_module(day, part) do
|
|
|
|
Module.concat(day_module(day), Macro.camelize("Part#{part_number(part)}"))
|
|
|
|
end
|
|
|
|
|
|
|
|
def day_module(day) do
|
|
|
|
Module.concat(AdventOfCode, Macro.camelize("Day#{day_number(day)}"))
|
|
|
|
end
|
|
|
|
|
2022-09-21 09:19:53 -04:00
|
|
|
def day_input_path(day), do: "priv/inputs/#{day_number(day)}.input"
|
|
|
|
|
2022-09-21 09:19:53 -04:00
|
|
|
defp day_number(day), do: String.pad_leading(day, 2, "0")
|
|
|
|
defp part_number(part), do: String.trim_leading(part, "0")
|
2022-09-21 09:19:53 -04:00
|
|
|
end
|