day 5 part 1

This commit is contained in:
2020-12-07 00:11:31 +01:00
parent 7be1ad5495
commit b8be3271a3
2 changed files with 851 additions and 0 deletions

27
day5/day5.py Normal file
View 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()