Skip to content

Commit

Permalink
Add validate_set function to check if the sum of cube amounts exceeds…
Browse files Browse the repository at this point in the history
… the limit
  • Loading branch information
samjowen committed Dec 27, 2023
1 parent eaf0a81 commit 5dfb413
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/day2/day2.ex
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,13 @@ defmodule Day2 do
def sum_map(map) do
Map.values(map) |> Enum.sum()
end

def validate_set(game_set_string, cube_limit) do
cube_map = parse_game_set_amounts(game_set_string)

case sum_map(cube_map) > cube_limit do
true -> false
false -> true
end
end
end

0 comments on commit 5dfb413

Please sign in to comment.