day 5 part 1
This commit is contained in:
27
day5/day5.py
Normal file
27
day5/day5.py
Normal file
@@ -0,0 +1,27 @@
|
||||
def getSeatID(boarding_pass):
|
||||
row = boarding_pass.replace('F', '0').replace('B', '1')[0:7]
|
||||
column = boarding_pass.replace('L', '0').replace('R', '1')[7:10]
|
||||
|
||||
row = (int('0b' + row, 2))
|
||||
column = (int('0b' + column, 2))
|
||||
|
||||
return (row * 8) + column
|
||||
|
||||
|
||||
def part1():
|
||||
file = open("input.txt")
|
||||
highest = 0
|
||||
for line in file:
|
||||
highest = max(getSeatID(line), highest)
|
||||
|
||||
print("Part 1: %d" % highest)
|
||||
|
||||
|
||||
def part2():
|
||||
file = open("input.txt")
|
||||
print("Part 2:")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
part1()
|
||||
part2()
|
||||
Reference in New Issue
Block a user