From 5d59234db4a32c85dd7dcb5adcf72e5544cb182a Mon Sep 17 00:00:00 2001 From: Caleb Webber Date: Sat, 2 Dec 2023 02:14:11 -0500 Subject: [PATCH] mix format --- lib/aoc_runner.ex | 26 +++++++++++++------------- test/aoc_test.exs | 9 +++++---- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/lib/aoc_runner.ex b/lib/aoc_runner.ex index c32b7e7..f04a45e 100644 --- a/lib/aoc_runner.ex +++ b/lib/aoc_runner.ex @@ -1,7 +1,7 @@ defmodule AOCRunner do @spec is_empty?(s :: String.t()) :: boolean() defp is_empty?(s) do - String.trim(s) |> String.length() == 0 + String.trim(s) |> String.length() == 0 end @spec both_empty?(a :: String.t(), b :: String.t()) :: boolean() @@ -11,25 +11,25 @@ defmodule AOCRunner do @spec run(advent :: Advent, part :: :part1 | :part2) :: nil def run(advent, part) do - # runs the advent execute method with the current line, # until two empty lines are sent - run_until_exit = fn line, acc -> + run_until_exit = fn line, acc -> {_, state} = acc - put_elem(acc, 1, advent.execute(line |> String.trim(), state)) |> - then(fn {last_line, s} -> - {(if both_empty?(line, last_line), do: :halt, else: :cont), {String.trim(line), s}} + put_elem(acc, 1, advent.execute(line |> String.trim(), state)) + |> then(fn {last_line, s} -> + {if(both_empty?(line, last_line), do: :halt, else: :cont), {String.trim(line), s}} end) end - IO.stream() |> - Enum.reduce_while( - {nil, advent.init_state(part)}, - &run_until_exit.(&1, &2)) |> - elem(1) |> - advent.get_answer() |> - IO.puts() + IO.stream() + |> Enum.reduce_while( + {nil, advent.init_state(part)}, + &run_until_exit.(&1, &2) + ) + |> elem(1) + |> advent.get_answer() + |> IO.puts() nil end diff --git a/test/aoc_test.exs b/test/aoc_test.exs index a426096..8a8b292 100644 --- a/test/aoc_test.exs +++ b/test/aoc_test.exs @@ -1,8 +1,9 @@ -defmodule AocTest do +defmodule Day1Test do use ExUnit.Case - doctest Aoc - test "greets the world" do - assert Aoc.hello() == :world + test "solve" do + {_, content} = File.read("./test/test1.txt") + IO.puts(Day1_2024.solve(content |> String.split("\n"))) + assert 1 == 1 end end