Skip to content

Commit

Permalink
Add day2_solve_part_2 function to calculate accumulated powers
Browse files Browse the repository at this point in the history
  • Loading branch information
samjowen committed Dec 29, 2023
1 parent 27f4fef commit 3424be4
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/advent_of_code2023.ex
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,16 @@ defmodule AdventOfCode2023 do

Enum.sum(valid_id_ints)
end

def day2_solve_part_2(input_file_path) do
games_list = Day1.parse_file(input_file_path)
accumulated_powers = []

Enum.reduce(games_list, accumulated_powers, fn game, acc ->
minimal_map = Day2.get_minimal_map(game)
power = Day2.get_power_of_map(minimal_map)
[power | acc]
end)
|> Enum.sum()
end
end

0 comments on commit 3424be4

Please sign in to comment.