aoc/06/06.exs

19 lines
518 B
Elixir

groups = File.read!("input.txt") |> String.split("\n\n")
groups
|> Enum.map(&String.replace(&1, "\n", ""))
|> Enum.map(&String.graphemes(&1))
|> Enum.map(&MapSet.new(&1))
|> Enum.map(&Enum.count(&1))
|> Enum.sum()
|> IO.inspect()
groups
|> Enum.map(&String.split(&1,"\n"))
|> Enum.map(&Enum.map(&1, fn x -> String.graphemes(x) end))
|> Enum.map(&Enum.map(&1, fn x -> MapSet.new(x) end))
|> Enum.map(&Enum.reduce(&1, fn x,y -> MapSet.intersection(x,y) end))
|> Enum.map(&Enum.count(&1))
|> Enum.sum()
|> IO.inspect()