Day 6 Part 1
This commit is contained in:
parent
3b03be8ff9
commit
bb507b4d61
2 changed files with 2064 additions and 0 deletions
21
2020/day6/day6.ex
Normal file
21
2020/day6/day6.ex
Normal 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()
|
||||
Loading…
Reference in a new issue