From 210ff58be53723b2313f85ae719640c34db06409 Mon Sep 17 00:00:00 2001 From: Sloane Perrault Date: Wed, 21 Sep 2022 09:19:53 -0400 Subject: [PATCH] wip: 2015 day 15 --- 2015/lib/2015/15.ex | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 2015/lib/2015/15.ex diff --git a/2015/lib/2015/15.ex b/2015/lib/2015/15.ex new file mode 100644 index 0000000..99ef125 --- /dev/null +++ b/2015/lib/2015/15.ex @@ -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