This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import copy | |
#given the position of one braket, the program has to output the position of the matching bracket | |
#EDIT: I did it yes finally! | |
def find_parens(s): | |
toret = {} | |
pstack = [] | |
for i, c in enumerate(s): | |
if c == '[': |