8000 AoC 2020, day 5 · tobiasvl/adventofcode@85b4298 · GitHub
[go: up one dir, main page]

Skip to content

Commit 85b4298

Browse files
committed
AoC 2020, day 5
1 parent 55d51b3 commit 85b4298

File tree

2 files changed

+785
-0
lines changed

2 files changed

+785
-0
lines changed

2020/05/boarding.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/python3
2+
def seat_id(boarding_pass):
3+
boarding_pass = boarding_pass.replace('F', '0').replace('B', '1').replace('L', '0').replace('R', '1')
4+
boarding_pass = int(boarding_pass, 2)
5+
row = boarding_pass >> 3
6+
seat = boarding_pass & 7
7+
return (row * 8) + seat
8+
9+
def main():
10+
passes = []
11+
with open('input') as f:
12+
passes = [line.strip() for line in f]
13+
14+
seat_ids = sorted([seat_id(boarding_pass) for boarding_pass in passes])
15+
highest_id = max(seat_ids)
16+
print(highest_id)
17+
18+
lowest_id = min(seat_ids)
19+
for seat in range(lowest_id, highest_id):
20+
if seat not in seat_ids:
21+
print(seat)
22+
23+
if __name__ == "__main__":
24+
main()

0 commit comments

Comments
 (0)
0