advent-of-code/2015/day01/day01.py
germax26 dde31570ed
Add 2015/
With original solutions from when I did them.
2024-12-02 19:17:00 +11:00

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