diff --git a/day6/day6part2.exs b/day6/day6part2.exs index ed74694..e727d4a 100644 --- a/day6/day6part2.exs +++ b/day6/day6part2.exs @@ -3,12 +3,14 @@ defmodule Day6Part2 do File.stream!("input") |> Stream.chunk_by(&(&1 == "\n")) |> 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] - - Map.delete(frequencies, ?\n) - |> Enum.count(fn {_, v} -> v == count end) + Enum.count(frequencies, fn {_, v} -> v == count end) end) |> Enum.sum() |> IO.puts()