Combine spilt and trim

This commit is contained in:
Adam Millerchip 2020-12-07 22:36:40 +09:00
parent a63c3aeb4e
commit b2503c0e5b
2 changed files with 2 additions and 4 deletions

View File

@ -30,8 +30,7 @@ defmodule Day7Part1 do
def input_to_tree(input) do
input
|> String.trim(".\n")
|> String.split(".\n")
|> String.split(".\n", trim: true)
|> Enum.map(&String.split(&1, " bags contain "))
|> Map.new(fn [parent, child_spec] -> {parent, parse_children(child_spec)} end)
end

View File

@ -16,8 +16,7 @@ defmodule Day7Part2 do
def input_to_tree(input) do
input
|> String.trim(".\n")
|> String.split(".\n")
|> String.split(".\n", trim: true)
|> Enum.map(&String.split(&1, " bags contain "))
|> Map.new(fn [parent, child_spec] -> {parent, parse_children(child_spec)} end)
end