Files
aoc/2015/01.py
2025-12-01 21:43:05 -06:00

26 lines
351 B
Python

# Fill Input
input = ""
try:
with open("01.txt", 'r', encoding='utf-8') as file:
input += file.read()
except Exception as e:
print(f"An error occurred: {e}")
# Result
res1, res2 = 0, 0
for i in range(len(input)):
match input[i]:
case '(':
res1 += 1
case ')':
res1 -= 1
if res1 < 0 and res2 == 0:
res2 = i+1
print(res1, res2)