Watch
1
0
Fork
You've already forked advent-of-code
0

Day 6 Part 2

This commit is contained in:
Jeremy Kaplan 2020-12-06 13:13:25 -08:00
commit d753c73ce1

View file

@ -16,6 +16,22 @@ defmodule Day6 do
|> Enum.map(&MapSet.size/1) |> Enum.map(&MapSet.size/1)
|> Enum.sum() |> Enum.sum()
end end
def part2 do
alphabet = String.codepoints("abcdefghijklmnopqrstuvwxyz")
read_input()
|> String.split("\n\n")
|> Enum.map(fn block ->
String.split(block)
|> Enum.reduce(MapSet.new(alphabet), fn line, set ->
MapSet.intersection(set, MapSet.new(String.codepoints(line)))
end)
end)
|> Enum.map(&MapSet.size/1)
|> Enum.sum()
end
end end
Day6.part1() |> IO.inspect() Day6.part1() |> IO.inspect()
Day6.part2() |> IO.inspect()