30 lines
592 B
Python
Executable File
30 lines
592 B
Python
Executable File
def solve1():
|
|
inputFile = open("input.txt", "r")
|
|
content = inputFile.read()
|
|
inputFile.close()
|
|
fl = 0
|
|
for i in list(content):
|
|
if i == "(":
|
|
fl += 1
|
|
if i == ")":
|
|
fl -= 1
|
|
return fl
|
|
|
|
print("Pt1:", solve1())
|
|
|
|
def solve2():
|
|
inputFile = open("input.txt", "r")
|
|
content = inputFile.read()
|
|
inputFile.close()
|
|
fl = 0
|
|
ix = 0
|
|
for i in list(content):
|
|
if i == "(":
|
|
fl += 1
|
|
if i == ")":
|
|
fl -= 1
|
|
if fl == -1:
|
|
return ix + 1
|
|
ix += 1
|
|
print("Pt2:", solve2())
|