aoc/2015/1/part2.py
2018-12-01 15:41:40 +00:00

17 lines
247 B
Python

with open('input.txt', 'r') as input:
pos = 0
char_pos = 0
text = input.readline()
for char in text :
if char == ')':
pos -= 1
elif char == '(':
pos += 1
char_pos += 1
if pos == -1:
print (char_pos)
break
input.close()