Skip to content

Instantly share code, notes, and snippets.

@rtt
Last active December 5, 2020 11:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rtt/94c51d4613979a153a9eb8d09a711379 to your computer and use it in GitHub Desktop.
Save rtt/94c51d4613979a153a9eb8d09a711379 to your computer and use it in GitHub Desktop.
def calc(ticket):
seat_id = 0
for i, instr in enumerate(ticket):
if instr in 'BR':
seat_id += 2**(9-i)
return seat_id
def part_1(data):
return max(calc(line) for line in data)
if __name__ == '__main__':
with open('input5.txt', 'r') as f:
inp = f.read().strip().split('\n')
print(part_1(inp))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment