-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathday_05a.py
More file actions
28 lines (24 loc) · 717 Bytes
/
day_05a.py
File metadata and controls
28 lines (24 loc) · 717 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env python3
def main():
f = open("../input/day_05_input")
max_seat_id = 0
for line in f:
min_row = 0
max_row = 128
min_col = 0
max_col = 8
for letter in line[0:7]:
if letter == "F":
max_row = (max_row + min_row) / 2
else:
min_row = (max_row + min_row) / 2
for letter in line[7:10]:
if letter == "L":
max_col = (max_col + min_col) / 2
else:
min_col = (max_col + min_col) / 2
max_seat_id = max(max_seat_id, 8 * (max_row - 1) + max_col - 1)
print(max_seat_id)
return max_seat_id
if __name__ == "__main__":
main()