diff --git a/2021/.formatter.exs b/2021/.formatter.exs new file mode 100644 index 0000000..d2cda26 --- /dev/null +++ b/2021/.formatter.exs @@ -0,0 +1,4 @@ +# Used by "mix format" +[ + inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"] +] diff --git a/2021/.gitignore b/2021/.gitignore new file mode 100644 index 0000000..7eeb530 --- /dev/null +++ b/2021/.gitignore @@ -0,0 +1,27 @@ +# The directory Mix will write compiled artifacts to. +/_build/ + +# If you run "mix test --cover", coverage assets end up here. +/cover/ + +# The directory Mix downloads your dependencies sources to. +/deps/ + +# Where third-party dependencies like ExDoc output generated docs. +/doc/ + +# Ignore .fetch files in case you like to edit your project deps locally. +/.fetch + +# If the VM crashes, it generates a dump, let's ignore it too. +erl_crash.dump + +# Also ignore archive artifacts (built via "mix archive.build"). +*.ez + +# Ignore package tarball (built via "mix hex.build"). +advent_of_code-*.tar + + +# Temporary files for e.g. tests +/tmp diff --git a/2021/.tool-versions b/2021/.tool-versions new file mode 100644 index 0000000..eda65d9 --- /dev/null +++ b/2021/.tool-versions @@ -0,0 +1,2 @@ +erlang 24.1.4 +elixir 1.12.3-otp-24 diff --git a/2021/README.md b/2021/README.md new file mode 100644 index 0000000..f246dcc --- /dev/null +++ b/2021/README.md @@ -0,0 +1,22 @@ +# Advent of Code 2021 + +<details> + <summary>Setup</summary> + + Using [asdf]: + + ```sh + asdf plugin add erlang + asdf plugin add elixir + asdf install + ``` +</details> + +| S | M | T | W | T | F | S | +| :-: | :-: | :-: | :-: | :-: | :-: | :-: | +| | | | 1 | 2 | 3 | 4 | +| 5 | 6 | 7 | 8 | 9 | 10 | 11 | +| 12 | 13 | 14 | 15 | 16 | 17 | 18 | +| 19 | 20 | 21 | 22 | 23 | 24 | 25 | + +[asdf]: https://asdf-vm.com/#/ diff --git a/2021/lib/advent_of_code.ex b/2021/lib/advent_of_code.ex new file mode 100644 index 0000000..33601c2 --- /dev/null +++ b/2021/lib/advent_of_code.ex @@ -0,0 +1,18 @@ +defmodule AdventOfCode do + @moduledoc """ + Documentation for `AdventOfCode`. + """ + + @doc """ + Hello world. + + ## Examples + + iex> AdventOfCode.hello() + :world + + """ + def hello do + :world + end +end diff --git a/2021/lib/mix/advent_of_code.ex b/2021/lib/mix/advent_of_code.ex new file mode 100644 index 0000000..7c6b7c2 --- /dev/null +++ b/2021/lib/mix/advent_of_code.ex @@ -0,0 +1,5 @@ +defmodule Mix.AdventOfCode do + @moduledoc """ + Helpers for `AdventOfCode` mix tasks. + """ +end diff --git a/2021/lib/mix/tasks/advent_of_code.gen.solution.exs b/2021/lib/mix/tasks/advent_of_code.gen.solution.exs new file mode 100644 index 0000000..2de107d --- /dev/null +++ b/2021/lib/mix/tasks/advent_of_code.gen.solution.exs @@ -0,0 +1,21 @@ +defmodule Mix.Tasks.AdventOfCode.Gen.Solution do + use Mix.Task + import Mix.Generator + + @shortdoc "Generate a new solution module" + + @moduledoc """ + #{@shortdoc}. + + Includes new solution module, test, and empty problem input. + + ## Examples + + # Generate solution modules, tests, and empty input for Day 2 + $ mix advent_of_code.gen.solution 2 + """ + + @impl Mix.Task + def run(_args) do + end +end diff --git a/2021/lib/mix/tasks/advent_of_code.solve.exs b/2021/lib/mix/tasks/advent_of_code.solve.exs new file mode 100644 index 0000000..645e550 --- /dev/null +++ b/2021/lib/mix/tasks/advent_of_code.solve.exs @@ -0,0 +1,18 @@ +defmodule Mix.Tasks.AdventOfCode.Solve do + use Mix.Task + + @shortdoc "Runs solution code with problem input" + + @moduledoc """ + #{@shortdoc}. + + ## Examples + + # Run Day 2, Part 1 solution program + $ mix advent_of_code.solve 2.1 + """ + + @impl Mix.Task + def run(_args) do + end +end diff --git a/2021/mix.exs b/2021/mix.exs new file mode 100644 index 0000000..949a228 --- /dev/null +++ b/2021/mix.exs @@ -0,0 +1,28 @@ +defmodule AdventOfCode.MixProject do + use Mix.Project + + def project do + [ + app: :advent_of_code, + version: "0.1.0", + elixir: "~> 1.11", + start_permanent: Mix.env() == :prod, + deps: deps() + ] + end + + # Run "mix help compile.app" to learn about applications. + def application do + [ + extra_applications: [:logger] + ] + end + + # Run "mix help deps" to learn about dependencies. + defp deps do + [ + # {:dep_from_hexpm, "~> 0.3.0"}, + # {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"} + ] + end +end diff --git a/2021/test/advent_of_code_test.exs b/2021/test/advent_of_code_test.exs new file mode 100644 index 0000000..8a98262 --- /dev/null +++ b/2021/test/advent_of_code_test.exs @@ -0,0 +1,8 @@ +defmodule AdventOfCodeTest do + use ExUnit.Case + doctest AdventOfCode + + test "greets the world" do + assert AdventOfCode.hello() == :world + end +end diff --git a/2021/test/test_helper.exs b/2021/test/test_helper.exs new file mode 100644 index 0000000..869559e --- /dev/null +++ b/2021/test/test_helper.exs @@ -0,0 +1 @@ +ExUnit.start()