Add 1 -> 5

This commit is contained in:
PedroEdiaz
2025-10-29 17:19:47 -06:00
commit 62dade14e1
5 changed files with 139 additions and 0 deletions

25
2015/1.py Normal file
View File

@@ -0,0 +1,25 @@
#!/usr/bin/env python3
# Fill Input
input = ""
try:
with open("1.txt", 'r', encoding='utf-8') as file:
input += file.read()
except Exception as e:
print(f"An error occurred: {e}")
# Part 1
print(input.count("(") - input.count(")"))
# Part 2
res = 0
for i in range(len(input)):
match input[i]:
case '(':
res += 1
case ')':
res -= 1
if res < 0:
print(i+1)
break