day 5
This commit is contained in:
parent
edaedf8a4c
commit
93ca6ada77
1 changed files with 6 additions and 9 deletions
15
05/05.py
15
05/05.py
|
@ -6,23 +6,20 @@ import re
|
||||||
maxid = 0
|
maxid = 0
|
||||||
ids = {}
|
ids = {}
|
||||||
for line in sys.stdin:
|
for line in sys.stdin:
|
||||||
rows = line[0:7]
|
rows = line[:7]
|
||||||
seat = line[7:10]
|
seat = line[7:]
|
||||||
|
|
||||||
rows = rows.replace('F', '0')
|
rows = rows.replace('F', '0').replace('B', '1')
|
||||||
rows = rows.replace('B', '1')
|
seat = seat.replace('R', '1').replace('L', '0')
|
||||||
seat = seat.replace('R', '1')
|
|
||||||
seat = seat.replace('L', '0')
|
|
||||||
|
|
||||||
row = int(rows, 2)
|
row = int(rows, 2)
|
||||||
column = int(seat, 2)
|
column = int(seat, 2)
|
||||||
seatid = row*8+column
|
seatid = row * 8 + column
|
||||||
#print(row, column, seatid)
|
|
||||||
ids[seatid] = 1
|
ids[seatid] = 1
|
||||||
if maxid < seatid:
|
if maxid < seatid:
|
||||||
maxid = seatid
|
maxid = seatid
|
||||||
|
|
||||||
|
|
||||||
print(1, maxid)
|
print(1, maxid)
|
||||||
|
|
||||||
seen = 0
|
seen = 0
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue