Compare commits

..

1 Commits

Author SHA1 Message Date
Shadowfacts 296c2e2e15
Day 6 2020-12-06 10:25:55 -05:00
1 changed files with 16 additions and 12 deletions

View File

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