mirror of
https://github.com/rjNemo/ai_advent_code_2024
synced 2026-06-06 02:26:44 +00:00
feat: Implement mul() instruction parsing and summation for Day 3
This commit is contained in:
parent
787427de18
commit
70b2cf2086
1 changed files with 11 additions and 2 deletions
|
|
@ -47,8 +47,17 @@ defmodule AdventCode2024.Solutions.Day03 do
|
|||
|
||||
defp solve_content(""), do: {:error, :no_input}
|
||||
defp solve_content(content) when is_binary(content) and content != "" do
|
||||
# TODO: Implement solution for part 1
|
||||
{:ok, 0}
|
||||
result =
|
||||
~r/mul\((\d{1,3}),(\d{1,3})\)/
|
||||
|> Regex.scan(content, capture: :all_but_first)
|
||||
|> Enum.map(fn [x, y] ->
|
||||
{x_int, _} = Integer.parse(x)
|
||||
{y_int, _} = Integer.parse(y)
|
||||
x_int * y_int
|
||||
end)
|
||||
|> Enum.sum()
|
||||
|
||||
{:ok, result}
|
||||
end
|
||||
|
||||
defp solve_part2_content(""), do: {:error, :no_input}
|
||||
|
|
|
|||
Loading…
Reference in a new issue