| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- file = open('input.txt','r')
- passes = file.readlines()
- def getRow(code):
- high = 127
- low = 0
- for c in code:
- print('Row Char: '+c)
- if c == 'F':
- high -=int( (high - low + 1) / 2)
- else:
- low +=int( (high - low + 1 ) / 2)
- print('low: ' + str(low) + ' high: ' + str(high))
- return low
- def getSeat(code):
- high = 7
- low = 0
- for c in code:
- print('Row Char: '+c)
- if c == 'L':
- high -=int( (high - low +1) / 2)
- else:
- low +=int( (high - low + 1) / 2)
- print('low: ' + str(low) + ' high: ' + str(high))
- return low
- maxSeat = 0
- seats = []
- #passes = ['FBFBBFFRLR','BFFFBBFRRR','FFFBBBFRRR','BBFFBBFRLL']
- for p in passes:
- row = getRow(p[:7])
- column = getSeat(p[7:10])
- seatID = (row * 8) + column
- seats.append(seatID)
- print(p)
- print('row: '+str(row))
- print('col: '+str(column))
- print('seat: '+str(seatID))
- if seatID > maxSeat:
- maxSeat = seatID
- last = 0
- preLast = 0
- seats = sorted(set(seats), key = lambda ele: seats.count(ele))
- #seats.sort()
- for s in seats:
- print(str(last) + ' vs ' + str(s))
- if s - 1 != last and s == last + 2:
- print('hole between ' + str(s) + ' and ' + str(last))
- preLast = last
- last = int(s)
- #print(str(maxSeat))
|