Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- lines = int(input())
- opening_brckt = 0
- closing_brckt = 0
- for i in range(lines):
- symbol = input()
- if symbol == "(":
- opening_brckt += 1
- elif symbol == ")":
- closing_brckt += 1
- if opening_brckt - closing_brckt == 2:
- break
- if opening_brckt == closing_brckt and opening_brckt != 0:
- print("BALANCED")
- else:
- print("UNBALANCED")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement