Compare commits

..

1 Commits

Author SHA1 Message Date
Shadowfacts 75745b42b7
Day 6 2020-12-06 10:57:43 -05:00
1 changed files with 12 additions and 16 deletions

View File

@ -41,25 +41,21 @@ defmodule Day6 do
str
|> String.replace(~r/\s/, "")
|> String.to_charlist()
|> Enum.into(MapSet.new())
|> MapSet.new()
end
def questions_with_all_yes(str) do
str
|> String.split("\n")
|> Enum.map(fn person ->
person
|> String.to_charlist()
|> MapSet.new()
end)
|> Enum.reduce(nil, fn person, acc ->
case acc do
nil ->
person
people =
str
|> String.split("\n")
|> Enum.map(fn person ->
person
|> String.to_charlist()
|> MapSet.new()
end)
_ ->
MapSet.intersection(acc, person)
end
end)
people
|> Enum.drop(1)
|> Enum.reduce(List.first(people), &MapSet.intersection/2)
end
end