https://programmers.co.kr/learn/courses/30/lessons/76502
def solution(s):
answer = 0
for i in range(len(s)):
stack = []
cnt = 0
tmp = s[i:] + s[:i]
for t in tmp:
if (t == '(') | (t == '{') | (t == '['):
stack.append(t)
if t == ')':
if stack !=[]:
if stack[-1] == '(':
cnt +=1
stack.pop()
elif t == '}':
if stack != []:
if stack[-1] == '{':
cnt +=1
stack.pop()
elif t == ']':
if stack != []:
if stack[-1] == '[':
cnt +=1
stack.pop()
if cnt == len(tmp)/2:
answer +=1
return answer