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