Combine spilt and trim
This commit is contained in:
parent
a63c3aeb4e
commit
b2503c0e5b
2 changed files with 2 additions and 4 deletions
|
@ -30,8 +30,7 @@ defmodule Day7Part1 do
|
||||||
|
|
||||||
def input_to_tree(input) do
|
def input_to_tree(input) do
|
||||||
input
|
input
|
||||||
|> String.trim(".\n")
|
|> String.split(".\n", trim: true)
|
||||||
|> String.split(".\n")
|
|
||||||
|> Enum.map(&String.split(&1, " bags contain "))
|
|> Enum.map(&String.split(&1, " bags contain "))
|
||||||
|> Map.new(fn [parent, child_spec] -> {parent, parse_children(child_spec)} end)
|
|> Map.new(fn [parent, child_spec] -> {parent, parse_children(child_spec)} end)
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,8 +16,7 @@ defmodule Day7Part2 do
|
||||||
|
|
||||||
def input_to_tree(input) do
|
def input_to_tree(input) do
|
||||||
input
|
input
|
||||||
|> String.trim(".\n")
|
|> String.split(".\n", trim: true)
|
||||||
|> String.split(".\n")
|
|
||||||
|> Enum.map(&String.split(&1, " bags contain "))
|
|> Enum.map(&String.split(&1, " bags contain "))
|
||||||
|> Map.new(fn [parent, child_spec] -> {parent, parse_children(child_spec)} end)
|
|> Map.new(fn [parent, child_spec] -> {parent, parse_children(child_spec)} end)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue