-
Notifications
You must be signed in to change notification settings - Fork 0
/
5-1.py
35 lines (30 loc) · 830 Bytes
/
5-1.py
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
29
30
31
32
33
34
import array as arr
f = open("Day5Board.txt", "r")
d = f.read().split("\n")
highest = 0
tmp = 0
def spl(s):
return [c for c in s]
for seat in d:
seat = spl(seat)
start = [0,127]
startRow = [0,7]
place = start[1] - (start[0] - 1)
placeRow = startRow[1] - (startRow[0] - 1)
for i in seat:
if i == 'F':
place = place / 2
start[1] = start[0] + place - 1
if i == 'B':
place = place / 2
start[0] = start[1] - (place - 1)
if i == 'L':
placeRow = placeRow / 2
startRow[1] = startRow[0] + placeRow - 1
if i == 'R':
placeRow = placeRow / 2
startRow[0] = startRow[1] - (placeRow - 1)
tmp = start[0] * 8 + startRow[0]
if tmp > highest:
highest = tmp
print(highest)