Files
python-aoc-2020/day05/part1.py
Sebastian Seedorf 110c9fd125 Day 5
2020-12-05 17:38:57 +01:00

21 lines
437 B
Python

lines = (x.strip() for x in open("input.txt"))
high = 0
def parse_binary_string(string: str, ones):
length = len(string) - 1
cnt = 0
for idx, val in enumerate(string):
cnt += 2 ** (length-idx) if val == ones else 0
return cnt
for line in lines:
row = parse_binary_string(line[:7], ones="B")
col = parse_binary_string(line[7:], ones="R")
num = row * 8 + col
high = max(num, high)
print(high)