import sys

seat_id = ['.']*1024

with open("day5/input_day5.txt") as f:
    l = f.readlines()

for line in l:
    row = list(range(128))
    seat = list(range(8))
    
    for c in line[:7]:
        if c == 'F':
            row = row[:len(row)//2]
        else:
            row = row[len(row)//2:]

    for c in line[7:10]:
        if c == 'R':
            seat = seat[len(seat)//2:]
        else:
            seat = seat[:len(seat)//2]

    id = row[0]*8+seat[0]
    seat_id[id] = 'x'

temp = seat_id[:]
temp.reverse()
index = len(temp) - temp.index('x') - 1
print(index)
bc84bb9e348b1774d1b0da5b6f506bc7d7890499
<mask token>

<mask token>
with open('day5/input_day5.txt') as f:
    l = f.readlines()
for line in l:
    row = list(range(128))
    seat = list(range(8))
    for c in line[:7]:
        if c == 'F':
            row = row[:len(row) // 2]
        else:
            row = row[len(row) // 2:]
    for c in line[7:10]:
        if c == 'R':
            seat = seat[len(seat) // 2:]
        else:
            seat = seat[:len(seat) // 2]
    id = row[0] * 8 + seat[0]
    seat_id[id] = 'x'
<mask token>
temp.reverse()
<mask token>
print(index)

<mask token>
seat_id = ['.'] * 1024
with open('day5/input_day5.txt') as f:
    l = f.readlines()
for line in l:
    row = list(range(128))
    seat = list(range(8))
    for c in line[:7]:
        if c == 'F':
            row = row[:len(row) // 2]
        else:
            row = row[len(row) // 2:]
    for c in line[7:10]:
        if c == 'R':
            seat = seat[len(seat) // 2:]
        else:
            seat = seat[:len(seat) // 2]
    id = row[0] * 8 + seat[0]
    seat_id[id] = 'x'
temp = seat_id[:]
temp.reverse()
index = len(temp) - temp.index('x') - 1
print(index)

import sys
seat_id = ['.'] * 1024
with open('day5/input_day5.txt') as f:
    l = f.readlines()
for line in l:
    row = list(range(128))
    seat = list(range(8))
    for c in line[:7]:
        if c == 'F':
            row = row[:len(row) // 2]
        else:
            row = row[len(row) // 2:]
    for c in line[7:10]:
        if c == 'R':
            seat = seat[len(seat) // 2:]
        else:
            seat = seat[:len(seat) // 2]
    id = row[0] * 8 + seat[0]
    seat_id[id] = 'x'
temp = seat_id[:]
temp.reverse()
index = len(temp) - temp.index('x') - 1
print(index)

import sys

seat_id = ['.']*1024

with open("day5/input_day5.txt") as f:
    l = f.readlines()

for line in l:
    row = list(range(128))
    seat = list(range(8))
    
    for c in line[:7]:
        if c == 'F':
            row = row[:len(row)//2]
        else:
            row = row[len(row)//2:]

    for c in line[7:10]:
        if c == 'R':
            seat = seat[len(seat)//2:]
        else:
            seat = seat[:len(seat)//2]

    id = row[0]*8+seat[0]
    seat_id[id] = 'x'

temp = seat_id[:]
temp.reverse()
index = len(temp) - temp.index('x') - 1
print(index)