1
0
Fork 0
advent-of-code/2021/lib/advent_of_code.ex

24 lines
622 B
Elixir
Raw Normal View History

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)
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")
end