diff --git a/06/06.exs b/06/06.exs new file mode 100644 index 0000000..2db22a6 --- /dev/null +++ b/06/06.exs @@ -0,0 +1,18 @@ +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()