File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change 33import re
44from typing import Dict , List
55
6+
67def 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+
1416def 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
2123if __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 ]),
You can’t perform that action at this time.
0 commit comments