aoc/2015/01/part2.py

20 lines
314 B
Python
Raw Permalink Normal View History

2019-01-02 01:12:02 +00:00
import os
path = os.path.dirname(os.path.abspath(__file__))
with open(path+'/input.txt', 'r') as input:
2018-11-29 17:10:49 +00:00
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()