Skip to content

Commit

Permalink
Refactor parse_game_number and add parse_game_sets
Browse files Browse the repository at this point in the history
  • Loading branch information
samjowen committed Dec 24, 2023
1 parent e3c809d commit 2096e9f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/day2/day2.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ defmodule Day2 do
def parse_game_number(game_string) do
String.split(game_string, " ", trim: true)
|> Enum.take(2)
|> List.last() |> String.replace(":", "")
|> List.last()
|> String.replace(":", "")
end

def parse_game_sets(game_string) do
Regex.replace(~r/\bGame (\d+):\s/, game_string, "")
|> String.split(";")
|> Enum.map(&String.trim/1)
end
end

0 comments on commit 2096e9f

Please sign in to comment.