+36
lib/day06.ex
+36
lib/day06.ex
···
1
+
defmodule Aoc2025.Day06 do
2
+
@moduledoc false
3
+
use Aoc2025.Template
4
+
5
+
def get_day, do: 6
6
+
7
+
def get_example,
8
+
do: """
9
+
123 328 51 64
10
+
45 64 387 23
11
+
6 98 215 314
12
+
* + * +
13
+
"""
14
+
15
+
def parse_input(input) do
16
+
input
17
+
|> String.trim()
18
+
|> String.split("\n")
19
+
|> Stream.map(&String.split/1)
20
+
end
21
+
22
+
def solve_part_1(input) do
23
+
input
24
+
|> Enum.reverse()
25
+
|> Enum.zip_with(&Function.identity/1)
26
+
|> Enum.map(fn [op_str | [first | rest]] ->
27
+
op = op_str_to_func(op_str)
28
+
29
+
Enum.reduce(rest, String.to_integer(first), fn num, acc -> op.(String.to_integer(num), acc) end)
30
+
end)
31
+
|> Enum.sum()
32
+
end
33
+
34
+
def op_str_to_func("*"), do: &Kernel.*/2
35
+
def op_str_to_func("+"), do: &Kernel.+/2
36
+
end