Refactor for readability
This commit is contained in:
parent
d11d007be9
commit
3e0f4451e0
1 changed files with 7 additions and 5 deletions
|
@ -3,12 +3,14 @@ defmodule Day6Part2 do
|
||||||
File.stream!("input")
|
File.stream!("input")
|
||||||
|> Stream.chunk_by(&(&1 == "\n"))
|
|> Stream.chunk_by(&(&1 == "\n"))
|
||||||
|> Stream.map(fn group ->
|
|> Stream.map(fn group ->
|
||||||
frequencies = group |> Enum.join() |> String.to_charlist() |> Enum.frequencies()
|
{count, frequencies} =
|
||||||
|
group
|
||||||
|
|> Enum.join()
|
||||||
|
|> String.to_charlist()
|
||||||
|
|> Enum.frequencies()
|
||||||
|
|> Map.pop(?\n)
|
||||||
|
|
||||||
count = frequencies[?\n]
|
Enum.count(frequencies, fn {_, v} -> v == count end)
|
||||||
|
|
||||||
Map.delete(frequencies, ?\n)
|
|
||||||
|> Enum.count(fn {_, v} -> v == count end)
|
|
||||||
end)
|
end)
|
||||||
|> Enum.sum()
|
|> Enum.sum()
|
||||||
|> IO.puts()
|
|> IO.puts()
|
||||||
|
|
Loading…
Reference in a new issue