Day 5
This commit is contained in:
20
day05/part1.py
Normal file
20
day05/part1.py
Normal file
@@ -0,0 +1,20 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user