AdventOfCode/2020/elixir/day6/day6part1.exs

19 lines
339 B
Elixir
Raw Normal View History

2020-12-06 06:04:15 +00:00
defmodule Day6Part1 do
def run do
2020-12-06 06:45:22 +00:00
File.stream!("input")
|> Stream.chunk_by(&(&1 == "\n"))
2020-12-06 06:04:15 +00:00
|> Stream.map(fn group ->
group
2020-12-06 06:45:22 +00:00
|> Enum.join()
2020-12-06 06:47:14 +00:00
|> String.to_charlist()
2020-12-06 06:04:15 +00:00
|> Enum.frequencies()
2020-12-06 06:47:14 +00:00
|> Map.delete(?\n)
2020-12-06 06:04:15 +00:00
|> Enum.count()
end)
|> Enum.sum()
|> IO.puts()
end
end
Day6Part1.run()