-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path5a.py
More file actions
32 lines (29 loc) · 847 Bytes
/
5a.py
File metadata and controls
32 lines (29 loc) · 847 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
29
30
31
32
#Advent of code
# 12/10/2020 day5 5a
filename = "data5.txt"
file = open(filename)
filestr = file.read()
a_list = filestr.split("\n")
maxindex = len(a_list)
#print(a_list)
print(f"maxindex={maxindex}, maxcolumns={len(a_list[0])}")
row_offset = [ 64, 32, 16, 8, 4, 2, 1 ]
col_offset = [ 4, 2, 1 ]
highest_sid = 0
for seat in a_list:
row_str = seat[0:7]
col_str = seat[7:10]
print(f"{row_str}, {col_str}")
row_id = 0
for i, char in enumerate(row_str):
if char == "B":
row_id = row_id + row_offset[i]
col_id = 0
for i, char in enumerate(col_str):
if char == "R":
col_id = col_id + col_offset[i]
sid = row_id * 8 + col_id
print(f"row_id = {row_id}, col_id = {col_id}, sid = {sid}")
if sid > highest_sid:
highest_sid = sid
print (f"highest_sid = {highest_sid}")