Advent-of-Code/2020/day 5/P1/binary_boarding.py

21 lines
442 B
Python
Raw Normal View History

2020-12-05 21:57:24 +01:00
seats = open("input.txt").read().split("\n")[:-1]
plane = [[i*8+j for j in range(8)] for i in range(128)]
taken = []
for seat in seats:
p = plane
for h in seat[:7]:
if h == "F":
p = p[:len(p)//2]
else:
p = p[len(p)//2:]
p = p[0]
for h in seat[7:]:
if h == "L":
p = p[:len(p)//2]
else:
p = p[len(p)//2:]
taken.append(p[0])
print(max(taken))