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