aoc2020/05/1.py

7 lines
347 B
Python
Raw Normal View History

2020-12-05 10:49:51 +00:00
from functools import reduce
from math import floor, ceil
shuffle = lambda l, h, s: reduce(lambda a, b: (a[0], floor((a[0]+a[1])/2)) if b in "FL" else (ceil((a[0]+a[1])/2), a[1]), s, (l, h))[0]
lines = [l for l in open("input", "r").read().split("\n") if l]
ids = [shuffle(0, 127, l[:7]) * 8 + shuffle(0, 7, l[7:]) for l in lines]
print(max(ids))