wip: 2015 day 15
This commit is contained in:
parent
d583b073d4
commit
210ff58be5
1 changed files with 26 additions and 0 deletions
26
2015/lib/2015/15.ex
Normal file
26
2015/lib/2015/15.ex
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
import AOC
|
||||||
|
|
||||||
|
aoc 2015, 15 do
|
||||||
|
def parse_ingredient(str) do
|
||||||
|
[name | properties] =
|
||||||
|
Regex.run(
|
||||||
|
~r/(\w+): capacity (-?\d+), durability (-?\d+), flavor (-?\d+), texture (-?\d+), calories (-?\d+)$/,
|
||||||
|
str,
|
||||||
|
capture: :all_but_first
|
||||||
|
)
|
||||||
|
|
||||||
|
[capacity, durability, flavor, texture, calories] =
|
||||||
|
properties |> Enum.map(&String.to_integer/1)
|
||||||
|
|
||||||
|
{name, [capacity, durability, flavor, texture], calories}
|
||||||
|
end
|
||||||
|
|
||||||
|
def p1 do
|
||||||
|
input_stream()
|
||||||
|
|> Stream.map(&parse_ingredient/1)
|
||||||
|
|> Enum.to_list()
|
||||||
|
end
|
||||||
|
|
||||||
|
def p2 do
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue