aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryan Brattlof <hello@bryanbrattlof.com>2020-12-13 16:50:55 -0500
committerBryan Brattlof <hello@bryanbrattlof.com>2020-12-13 16:50:55 -0500
commit795eaf866216339549550060030c7e4f544af3a2 (patch)
tree0653d0e73575616f13642f3c6a0fa5ca7e25ded8
parentd491af6d5534348450de3be4a017396656a5f9a0 (diff)
downloadadvent-of-code-795eaf866216339549550060030c7e4f544af3a2.tar.gz
advent-of-code-795eaf866216339549550060030c7e4f544af3a2.tar.bz2
day 5.2 of Advent of Code 2020
-rw-r--r--2020/day05/binary-bording.py11
-rw-r--r--2020/day05/readme.rst17
2 files changed, 28 insertions, 0 deletions
diff --git a/2020/day05/binary-bording.py b/2020/day05/binary-bording.py
index d3cb284..6af3833 100644
--- a/2020/day05/binary-bording.py
+++ b/2020/day05/binary-bording.py
@@ -41,3 +41,14 @@ with open('data/boarding-passes.txt') as f:
hi = max(bp.seat_id for bp in seats)
print(f'biggest seat: {hi}')
+
+# Part Two
+
+with open('data/boarding-passes.txt') as f:
+ seat_ids = [bp.seat_id for bp in (boarding(bp.strip()) for bp in f)]
+
+lo = min(seat_ids)
+hi = max(seat_ids)
+
+print([x for x in range(lo, hi)
+ if x not in seat_ids and x - 1 in seat_ids and x + 1 in seat_ids])
diff --git a/2020/day05/readme.rst b/2020/day05/readme.rst
index 58a1944..36af125 100644
--- a/2020/day05/readme.rst
+++ b/2020/day05/readme.rst
@@ -60,3 +60,20 @@ seat ID on a boarding pass?
Your puzzle answer was 970.
The first half of this puzzle is complete! It provides one gold star: *
+
+Part Two
+########
+
+Ding! The "fasten seat belt" signs have turned on. Time to find your seat.
+
+It's a completely full flight, so your seat should be the only missing boarding
+pass in your list. However, there's a catch: some of the seats at the very front
+and back of the plane don't exist on this aircraft, so they'll be missing from
+your list as well.
+
+Your seat wasn't at the very front or back, though; the seats with IDs +1 and
+-1 from yours will be in your list.
+
+What is the ID of your seat?
+
+That's the right answer! You are one gold star closer to saving your vacation.