learning about elixir syntax wheeee
This commit is contained in:
parent
3d7a36ec6f
commit
6ee2030df0
1 changed files with 18 additions and 0 deletions
18
06/06.exs
Normal file
18
06/06.exs
Normal 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()
|
Loading…
Reference in a new issue