learning about elixir syntax wheeee

This commit is contained in:
a 2020-12-06 15:13:45 -06:00
parent 3d7a36ec6f
commit 6ee2030df0

18
06/06.exs Normal file
View file

@ -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()