From 71b9172f98bee76044ebbfe0579064768d267cb8 Mon Sep 17 00:00:00 2001 From: Samuel Owen Date: Wed, 27 Dec 2023 22:09:42 +0000 Subject: [PATCH] Add day 1 and day 2 solutions --- lib/advent_of_code2023.ex | 6 ++++++ test/day2/day2_solves_tests.exs | 12 ++++++++++++ test/day2/mocks/part-2-test-case.txt | 5 +++++ 3 files changed, 23 insertions(+) create mode 100644 test/day2/day2_solves_tests.exs create mode 100644 test/day2/mocks/part-2-test-case.txt diff --git a/lib/advent_of_code2023.ex b/lib/advent_of_code2023.ex index ed9f3b0..674e1e6 100644 --- a/lib/advent_of_code2023.ex +++ b/lib/advent_of_code2023.ex @@ -3,6 +3,7 @@ defmodule AdventOfCode2023 do Documentation for `AdventOfCode2023`. """ + # Day 1 def day1_solve_part_1(input_file_path) do Day1.parse_file(input_file_path) |> Enum.map(&Day1.combine_first_and_last_number/1) @@ -15,4 +16,9 @@ defmodule AdventOfCode2023 do |> Enum.map(&Day1.combine_first_and_last_number/1) |> Enum.sum() end + + # Day 2 + def day2_solve_part2(input_file_path) do + Day1.parse_file(input_file_path) + end end diff --git a/test/day2/day2_solves_tests.exs b/test/day2/day2_solves_tests.exs new file mode 100644 index 0000000..2bb8894 --- /dev/null +++ b/test/day2/day2_solves_tests.exs @@ -0,0 +1,12 @@ +defmodule Day2SolvesTest do + @moduledoc """ + This module contains tests for the Day2 module. + """ + + use ExUnit.Case + doctest AdventOfCode2023 + + test "solves the day 2 part II puzzle correctly" do + assert AdventOfCode2023.day2_solve_part_2("./test/day2/mocks/part2-test-case.txt") == 8 + end +end diff --git a/test/day2/mocks/part-2-test-case.txt b/test/day2/mocks/part-2-test-case.txt new file mode 100644 index 0000000..1cd7d33 --- /dev/null +++ b/test/day2/mocks/part-2-test-case.txt @@ -0,0 +1,5 @@ +Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green +Game 2: 1 blue, 2 green; 3 green, 4 blue, 1 red; 1 green, 1 blue +Game 3: 8 green, 6 blue, 20 red; 5 blue, 4 red, 13 green; 5 green, 1 red +Game 4: 1 green, 3 red, 6 blue; 3 green, 6 red; 3 green, 15 blue, 14 red +Game 5: 6 red, 1 blue, 3 green; 2 blue, 1 red, 2 green \ No newline at end of file