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

Day 5 Part 2

This commit is contained in:
Jeremy Kaplan 2020-12-04 21:46:30 -08:00
commit 3b03be8ff9

View file

@ -41,6 +41,27 @@ defmodule Day5 do
|> Enum.map(&seat_id/1)
|> Enum.max()
end
defp find_hole(seat_ids) do
[{lo, hi}] =
Enum.zip(
Enum.slice(seat_ids, 0..-2),
Enum.slice(seat_ids, 1..-1)
)
|> Enum.filter(fn {a, b} -> b - a != 1 end)
lo + 1
end
def part2 do
read_input()
|> String.split()
|> Enum.map(&parse_seat/1)
|> Enum.map(&seat_id/1)
|> Enum.sort()
|> find_hole
end
end
Day5.part1() |> IO.inspect()
Day5.part2() |> IO.inspect()