Skip to content

Instantly share code, notes, and snippets.

@neoneo40
Last active August 29, 2015 14:11
Show Gist options
  • Save neoneo40/9b79cd16b7d5de65a625 to your computer and use it in GitHub Desktop.
Save neoneo40/9b79cd16b7d5de65a625 to your computer and use it in GitHub Desktop.
Test Brackets
import unittest
from brackets import well_matched
class TestBrackets(unittest.TestCase):
def testBrackets(self):
s = '''()()
({[}])
({}[(){}])
)
}
}}}
{}[]()
{[([()])]}
{[([()])]'''
problems = s.split('\n')
# answers = [True, False, True, False, False, False, True, True, False]
answers = ['YES', 'NO', 'YES', 'NO', 'NO', 'NO', 'YES', 'YES', 'NO']
d = {}
for k, v in zip(problems, answers):
d[k] = v
for k, v in d.items():
test_answer = well_matched(k)
self.assertEqual(test_answer, v)
if __name__ == '__main__':
unittest.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment