From 835ad00ed1ff5cc156a7527eeff9b49b38379198 Mon Sep 17 00:00:00 2001 From: sloane Date: Wed, 3 Dec 2025 09:38:00 -0500 Subject: [PATCH] setup 2025 --- 2025/.env | 1 + 2025/.formatter.exs | 4 ++++ 2025/.gitignore | 25 ++++++++++++++++++++++ 2025/README.md | 9 ++++++++ 2025/config/config.exs | 3 +++ 2025/config/dev.exs | 1 + 2025/config/prod.exs | 1 + 2025/config/runtime.exs | 3 +++ 2025/config/test.exs | 1 + 2025/lib/aoc.ex | 45 +++++++++++++++++++++++++++++++++++++++ 2025/lib/aoc/day_1.ex | 1 + 2025/mise.toml | 6 ++++++ 2025/mix.exs | 27 +++++++++++++++++++++++ 2025/mix.lock | 11 ++++++++++ 2025/priv/inputs/.gitkeep | 0 2025/test/test_helper.exs | 1 + README.md | 2 ++ 17 files changed, 141 insertions(+) create mode 100644 2025/.env create mode 100644 2025/.formatter.exs create mode 100644 2025/.gitignore create mode 100644 2025/README.md create mode 100644 2025/config/config.exs create mode 100644 2025/config/dev.exs create mode 100644 2025/config/prod.exs create mode 100644 2025/config/runtime.exs create mode 100644 2025/config/test.exs create mode 100644 2025/lib/aoc.ex create mode 100644 2025/lib/aoc/day_1.ex create mode 100644 2025/mise.toml create mode 100644 2025/mix.exs create mode 100644 2025/mix.lock create mode 100644 2025/priv/inputs/.gitkeep create mode 100644 2025/test/test_helper.exs diff --git a/2025/.env b/2025/.env new file mode 100644 index 0000000..dba2989 --- /dev/null +++ b/2025/.env @@ -0,0 +1 @@ +SESSION_COOKIE=53616c7465645f5f72c2167a886b5ad84b79c7bd0781bfbf2cfd4814bcee55666ef54a7ff19e973043098359e30df3263605e989b7faf91439b0cfc453358b41 diff --git a/2025/.formatter.exs b/2025/.formatter.exs new file mode 100644 index 0000000..d2cda26 --- /dev/null +++ b/2025/.formatter.exs @@ -0,0 +1,4 @@ +# Used by "mix format" +[ + inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"] +] diff --git a/2025/.gitignore b/2025/.gitignore new file mode 100644 index 0000000..96d9bb6 --- /dev/null +++ b/2025/.gitignore @@ -0,0 +1,25 @@ +# 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/ + +# Temporary files, for example, from tests. +/tmp/ + +# 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"). +aoc-*.tar + +/priv/inputs/*.txt diff --git a/2025/README.md b/2025/README.md new file mode 100644 index 0000000..93d08c4 --- /dev/null +++ b/2025/README.md @@ -0,0 +1,9 @@ +# Advent of Code 2025 + +| S | M | T | W | T | F | S | +| :-: | :-: | :-: | :-: | :-: | :-: | :-: | +| | 1 | 2 | 3 | 4 | 5 | 6 | +| 7 | 8 | 9 | 10 | 11 | 12 | | + + + diff --git a/2025/config/config.exs b/2025/config/config.exs new file mode 100644 index 0000000..d1186fe --- /dev/null +++ b/2025/config/config.exs @@ -0,0 +1,3 @@ +import Config + +import_config "#{config_env()}.exs" diff --git a/2025/config/dev.exs b/2025/config/dev.exs new file mode 100644 index 0000000..becde76 --- /dev/null +++ b/2025/config/dev.exs @@ -0,0 +1 @@ +import Config diff --git a/2025/config/prod.exs b/2025/config/prod.exs new file mode 100644 index 0000000..becde76 --- /dev/null +++ b/2025/config/prod.exs @@ -0,0 +1 @@ +import Config diff --git a/2025/config/runtime.exs b/2025/config/runtime.exs new file mode 100644 index 0000000..640e66d --- /dev/null +++ b/2025/config/runtime.exs @@ -0,0 +1,3 @@ +import Config + +config :aoc, session_cookie: System.fetch_env!("SESSION_COOKIE") diff --git a/2025/config/test.exs b/2025/config/test.exs new file mode 100644 index 0000000..becde76 --- /dev/null +++ b/2025/config/test.exs @@ -0,0 +1 @@ +import Config diff --git a/2025/lib/aoc.ex b/2025/lib/aoc.ex new file mode 100644 index 0000000..7fa251b --- /dev/null +++ b/2025/lib/aoc.ex @@ -0,0 +1,45 @@ +defmodule Aoc do + defmacro input do + day = + case Regex.run(~r/^Elixir\.Aoc\.Day(\d+)$/, "#{__CALLER__.module}", capture: :all_but_first) do + [day_str] -> + String.to_integer(day_str) + + _ -> + raise "`input/0` must be called from a module of the format `Aoc.Day`. Called in module #{inspect(__CALLER__.module)}" + end + + quote do + input(unquote(day)) + end + end + + def input(day) do + input_file = :code.priv_dir(:aoc) |> Path.join("inputs/#{day}.txt") + + if File.exists?(input_file) do + File.read!(input_file) + else + input = download_input(day) + + File.write!(input_file, input) + + input + end + end + + def lines(str) do + String.split(str, "\n", trim: true) + end + + defp download_input(day) do + Req.request!( + url: "https://adventofcode.com/2025/day/#{day}/input", + headers: [cookie: "session=#{session_cookie()}"] + ).body + end + + defp session_cookie do + Application.fetch_env!(:aoc, :session_cookie) + end +end diff --git a/2025/lib/aoc/day_1.ex b/2025/lib/aoc/day_1.ex new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/2025/lib/aoc/day_1.ex @@ -0,0 +1 @@ + diff --git a/2025/mise.toml b/2025/mise.toml new file mode 100644 index 0000000..29156dc --- /dev/null +++ b/2025/mise.toml @@ -0,0 +1,6 @@ +[env] +_.file = '.env' + +[tools] +elixir = "1.19.4-otp-28" +erlang = "28.2" diff --git a/2025/mix.exs b/2025/mix.exs new file mode 100644 index 0000000..cbf3c15 --- /dev/null +++ b/2025/mix.exs @@ -0,0 +1,27 @@ +defmodule Aoc.MixProject do + use Mix.Project + + def project do + [ + app: :aoc, + version: "0.1.0", + elixir: "~> 1.19", + 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 + [ + {:req, "~> 0.5.16"} + ] + end +end diff --git a/2025/mix.lock b/2025/mix.lock new file mode 100644 index 0000000..2e43e09 --- /dev/null +++ b/2025/mix.lock @@ -0,0 +1,11 @@ +%{ + "finch": {:hex, :finch, "0.20.0", "5330aefb6b010f424dcbbc4615d914e9e3deae40095e73ab0c1bb0968933cadf", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mint, "~> 1.6.2 or ~> 1.7", [hex: :mint, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.4 or ~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:nimble_pool, "~> 1.1", [hex: :nimble_pool, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "2658131a74d051aabfcba936093c903b8e89da9a1b63e430bee62045fa9b2ee2"}, + "hpax": {:hex, :hpax, "1.0.3", "ed67ef51ad4df91e75cc6a1494f851850c0bd98ebc0be6e81b026e765ee535aa", [:mix], [], "hexpm", "8eab6e1cfa8d5918c2ce4ba43588e894af35dbd8e91e6e55c817bca5847df34a"}, + "jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"}, + "mime": {:hex, :mime, "2.0.7", "b8d739037be7cd402aee1ba0306edfdef982687ee7e9859bee6198c1e7e2f128", [:mix], [], "hexpm", "6171188e399ee16023ffc5b76ce445eb6d9672e2e241d2df6050f3c771e80ccd"}, + "mint": {:hex, :mint, "1.7.1", "113fdb2b2f3b59e47c7955971854641c61f378549d73e829e1768de90fc1abf1", [:mix], [{:castore, "~> 0.1.0 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:hpax, "~> 0.1.1 or ~> 0.2.0 or ~> 1.0", [hex: :hpax, repo: "hexpm", optional: false]}], "hexpm", "fceba0a4d0f24301ddee3024ae116df1c3f4bb7a563a731f45fdfeb9d39a231b"}, + "nimble_options": {:hex, :nimble_options, "1.1.1", "e3a492d54d85fc3fd7c5baf411d9d2852922f66e69476317787a7b2bb000a61b", [:mix], [], "hexpm", "821b2470ca9442c4b6984882fe9bb0389371b8ddec4d45a9504f00a66f650b44"}, + "nimble_pool": {:hex, :nimble_pool, "1.1.0", "bf9c29fbdcba3564a8b800d1eeb5a3c58f36e1e11d7b7fb2e084a643f645f06b", [:mix], [], "hexpm", "af2e4e6b34197db81f7aad230c1118eac993acc0dae6bc83bac0126d4ae0813a"}, + "req": {:hex, :req, "0.5.16", "99ba6a36b014458e52a8b9a0543bfa752cb0344b2a9d756651db1281d4ba4450", [:mix], [{:brotli, "~> 0.3.1", [hex: :brotli, repo: "hexpm", optional: true]}, {:ezstd, "~> 1.0", [hex: :ezstd, repo: "hexpm", optional: true]}, {:finch, "~> 0.17", [hex: :finch, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:mime, "~> 2.0.6 or ~> 2.1", [hex: :mime, repo: "hexpm", optional: false]}, {:nimble_csv, "~> 1.0", [hex: :nimble_csv, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "974a7a27982b9b791df84e8f6687d21483795882a7840e8309abdbe08bb06f09"}, + "telemetry": {:hex, :telemetry, "1.3.0", "fedebbae410d715cf8e7062c96a1ef32ec22e764197f70cda73d82778d61e7a2", [:rebar3], [], "hexpm", "7015fc8919dbe63764f4b4b87a95b7c0996bd539e0d499be6ec9d7f3875b79e6"}, +} diff --git a/2025/priv/inputs/.gitkeep b/2025/priv/inputs/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/2025/test/test_helper.exs b/2025/test/test_helper.exs new file mode 100644 index 0000000..869559e --- /dev/null +++ b/2025/test/test_helper.exs @@ -0,0 +1 @@ +ExUnit.start() diff --git a/README.md b/README.md index 32c022c..87eb0fb 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ | [2022] | **14/50** 🌟 | Elixir, Haskell | | [2023] | **19/50** 🌟 | Elixir, Haskell | | [2024] | **30/50** 🌟 | Elixir | +| [2025] | **0/24** 🌟 | Elixir | | **Total** | **186** 🌟| | [2015]: ./2015 @@ -25,3 +26,4 @@ [2022]: ./2022 [2023]: ./2023 [2024]: ./2024 +[2025]: ./2025