advent-of-code/2015/day01/day01.py

30 lines
592 B
Python
Raw Normal View History

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())