File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
Filter options
Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
Original file line number Diff line number Diff line change
1
+ def Evaluate (str ):
2
+ stack = []
3
+ set1 , set2 = "<({[" , ">)}]"
4
+ for c in str :
5
+ if c in set1 :
6
+ #print "c in pushChars, APPENDING: ", c
7
+ stack .append (c )
8
+ elif c in set2 :
9
+ #print "c in popChars: ", c
10
+ if len (stack )== 0 :
11
+ return False
12
+ else :
13
+ stackTop = stack .pop ()
14
+ #print "POPPING" , stackTop
15
+ balancingBracket = set1 [set2 .index (c )]
16
+ if stackTop != balancingBracket :
17
+ #print "THIS NOW"
18
+ return False
19
+ #finally everything should be popped
20
+ if len (stack )== 0 :
21
+ return True
22
+ else :
23
+ return False
24
+
25
+ result = Evaluate ("<html><head><body><h1>Still working on it</h1></body></head></html>" )
26
+ print "Bracket Validator: " , result
27
+ result = Evaluate ("<html><head><body><h1>Still working on it</h1</body></head></html>" )
28
+ print "Bracket Validator: " , result
You can’t perform that action at this time.
0 commit comments