2020-12-06 15:04:15 +09:00
|
|
|
defmodule Day6Part2 do
|
|
|
|
def run do
|
2020-12-06 15:45:22 +09:00
|
|
|
File.stream!("input")
|
|
|
|
|> Stream.chunk_by(&(&1 == "\n"))
|
2020-12-06 15:04:15 +09:00
|
|
|
|> Stream.map(fn group ->
|
2020-12-06 16:03:34 +09:00
|
|
|
{count, frequencies} =
|
|
|
|
group
|
|
|
|
|> Enum.join()
|
|
|
|
|> String.to_charlist()
|
|
|
|
|> Enum.frequencies()
|
|
|
|
|> Map.pop(?\n)
|
2020-12-06 15:04:15 +09:00
|
|
|
|
2020-12-06 16:03:34 +09:00
|
|
|
Enum.count(frequencies, fn {_, v} -> v == count end)
|
2020-12-06 15:04:15 +09:00
|
|
|
end)
|
|
|
|
|> Enum.sum()
|
|
|
|
|> IO.puts()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
Day6Part2.run()
|