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

Day 6 Part 1

This commit is contained in:
Jeremy Kaplan 2020-12-06 13:06:48 -08:00
commit bb507b4d61
2 changed files with 2064 additions and 0 deletions

21
2020/day6/day6.ex Normal file
View file

@ -0,0 +1,21 @@
defmodule Day6 do
defp read_input do
Path.expand('input', Path.dirname(__ENV__.file))
|> File.read!()
end
def part1 do
read_input()
|> String.split("\n\n")
|> Enum.map(fn block ->
String.split(block)
|> Enum.reduce(MapSet.new(), fn line, set ->
MapSet.union(set, MapSet.new(String.codepoints(line)))
end)
end)
|> Enum.map(&MapSet.size/1)
|> Enum.sum()
end
end
Day6.part1() |> IO.inspect()

2043
2020/day6/input Normal file

File diff suppressed because it is too large Load diff