Add comments for clarity
This commit is contained in:
parent
c6a64056c6
commit
d4c0fdb000
2 changed files with 3 additions and 0 deletions
|
@ -20,6 +20,7 @@ defmodule Day7Part1 do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# %{"shiny gold" => ["pale magenta", "striped tomato", ...]}
|
||||||
def invert_tree(tree) do
|
def invert_tree(tree) do
|
||||||
Enum.reduce(tree, %{}, fn {parent, children}, inverted_tree ->
|
Enum.reduce(tree, %{}, fn {parent, children}, inverted_tree ->
|
||||||
Enum.reduce(children, inverted_tree, fn {_n, child}, inverted_tree ->
|
Enum.reduce(children, inverted_tree, fn {_n, child}, inverted_tree ->
|
||||||
|
@ -28,6 +29,7 @@ defmodule Day7Part1 do
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# %{"shiny gold" => [{5, "pale brown"}, {2, "light red"}, {3, "drab lime"}]}
|
||||||
def input_to_tree(input) do
|
def input_to_tree(input) do
|
||||||
input
|
input
|
||||||
|> String.split(".\n", trim: true)
|
|> String.split(".\n", trim: true)
|
||||||
|
|
|
@ -14,6 +14,7 @@ defmodule Day7Part2 do
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# %{"shiny gold" => [{5, "pale brown"}, {2, "light red"}, {3, "drab lime"}]}
|
||||||
def input_to_tree(input) do
|
def input_to_tree(input) do
|
||||||
input
|
input
|
||||||
|> String.split(".\n", trim: true)
|
|> String.split(".\n", trim: true)
|
||||||
|
|
Loading…
Reference in a new issue