Day 5 Part 2
This commit is contained in:
parent
0ba3fd1159
commit
3b03be8ff9
1 changed files with 21 additions and 0 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Reference in a new issue