Skip to content

Commit ac65be2

Browse files
committed
Nicer formatting
1 parent f8bbdbc commit ac65be2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

day05/day05.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,26 @@
33
import re
44
from typing import Dict, List
55

6+
67
def calculate_bsp(code: str, subrange: List[int]) -> List[int]:
78
for char in code:
89
if char == "F" or char == "L":
9-
subrange = subrange[:int(len(subrange)/2)]
10+
subrange = subrange[: int(len(subrange) / 2)]
1011
if char == "B" or char == "R":
11-
subrange = subrange[int(len(subrange)/2):]
12+
subrange = subrange[int(len(subrange) / 2) :]
1213
return subrange
1314

15+
1416
def calculate_seat(seat: str) -> int:
1517
column = calculate_bsp(seat[:7], list(range(128)))[0]
1618
row = calculate_bsp(seat[7:], list(range(8)))[0]
1719
print(column, row)
18-
return (column*8 + row)
20+
return column * 8 + row
1921

2022

2123
if __name__ == "__main__":
2224
with open(sys.argv[1], "r") as infile:
23-
seatcodes =[nextline.strip() for nextline in infile]
25+
seatcodes = [nextline.strip() for nextline in infile]
2426
print(
2527
"part 1: ",
2628
max([calculate_seat(seat) for seat in seatcodes]),

0 commit comments

Comments
 (0)