Compare commits
1 Commits
296c2e2e15
...
75745b42b7
Author | SHA1 | Date |
---|---|---|
Shadowfacts | 75745b42b7 |
|
@ -41,10 +41,11 @@ 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
|
||||
people =
|
||||
str
|
||||
|> String.split("\n")
|
||||
|> Enum.map(fn person ->
|
||||
|
@ -52,14 +53,9 @@ defmodule Day6 do
|
|||
|> String.to_charlist()
|
||||
|> MapSet.new()
|
||||
end)
|
||||
|> Enum.reduce(nil, fn person, acc ->
|
||||
case acc do
|
||||
nil ->
|
||||
person
|
||||
|
||||
_ ->
|
||||
MapSet.intersection(acc, person)
|
||||
end
|
||||
end)
|
||||
people
|
||||
|> Enum.drop(1)
|
||||
|> Enum.reduce(List.first(people), &MapSet.intersection/2)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue