Add matching brackets implementation for U6
This commit is contained in:
parent
8107a35409
commit
b42417b424
12
u6/matching-brackets.py
Normal file
12
u6/matching-brackets.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
def is_paired(input_string):
|
||||||
|
spisok = []
|
||||||
|
slovnik = {')': '(', ']': '[', '}': '{'}
|
||||||
|
|
||||||
|
for gnx in input_string:
|
||||||
|
if gnx in "([{":
|
||||||
|
spisok.append(gnx)
|
||||||
|
elif gnx in ")]}":
|
||||||
|
if not spisok or spisok[-1] != slovnik[gnx]:
|
||||||
|
return False
|
||||||
|
spisok.pop()
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user