rename n.py -> 0n.py
This commit is contained in:
25
2015/01.py
Normal file
25
2015/01.py
Normal file
@@ -0,0 +1,25 @@
|
||||
# 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)
|
||||
Reference in New Issue
Block a user